Created
March 10, 2024 04:49
-
-
Save whamtet/6792ff0545bf2e030b85dca8184b18d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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