Skip to content

Instantly share code, notes, and snippets.

@whamtet
Created March 10, 2024 04:49
Show Gist options
  • Save whamtet/6792ff0545bf2e030b85dca8184b18d6 to your computer and use it in GitHub Desktop.
Save whamtet/6792ff0545bf2e030b85dca8184b18d6 to your computer and use it in GitHub Desktop.
(ns email-edit.core
(:import
java.util.Base64))
(def encoder (Base64/getMimeEncoder))
(def decoder (Base64/getMimeDecoder))
(defn decode [^String s]
(String. (.decode decoder s)))
(defn encode [^String s]
(->> s .getBytes (.encodeToString encoder)))
(def start "Content-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: base64")
(def end "----boundary")
(def src (slurp "src.eml"))
(def snippet
(-> src
(.split start)
second
(.split end)
first
.trim))
(def html
(-> snippet
decode
(.replace "BLNGSW" "BLNGSV")
(.replace "Sat 09 Mar" "Sat 06 Apr")
encode))
(spit "dest.eml"
(.replace src snippet html))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment