Skip to content

Instantly share code, notes, and snippets.

@devth
Last active December 12, 2015 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devth/4751606 to your computer and use it in GitHub Desktop.
Save devth/4751606 to your computer and use it in GitHub Desktop.
(def m {:from #<IMAPAddress foo@gmail.com>,
:subject "Re: A friendly message",
:sender #<IMAPAddress foo.com>,
:multipart? true,
:content-type "multipart/ALTERNATIVE; boundary=bcaec5524106840d9e04d4ee1246",
:body [{"TEXT/PLAIN; charset=ISO-8859-1" "Lol.\r\n\r\n\r\nOn"} {"TEXT/HTML; charset=ISO-8859-1" "<div dir=\"ltr\">Lol.</div>"}]})
(defn- plain-key [m] (first (filter #(re-find #"TEXT/PLAIN" %) (keys m))))
(defn- plain-body [m] (let [body (first (:body m))]
(body (plain-key body))))
(plain-body m)
;=> "Lol.\r\n\r\n\r\nOn Mon, Feb 4, 2013 at 3:00 PM, Foo <foo@gmail.com> wrote:\r\n\r\n>\r\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment