A Clojure library that makes extracting attachments from email simple.
Example - extract a CSV file from an email:
;; example: a raw .eml file as an input-stream
(->> my-email-stream
email/content-types
(filter email/csv?)
first
email/content-stream)
The email/content-stream
will return the attached file as a stream
.
The library includes some helpers for determining file types:
email/csv?
email/excel?
email/ms-word?
email/pdf?
email/xml?
Example output from the email/content-types
function:
({:content-type "text/plain; charset=\"utf-8\"",
:data #object[ ... MimeBodyPart ... ]}
{:content-type "text/html; charset=\"utf-8\"",
:data #object[ ... MimeBodyPart ... ]}
{:content-type "text/csv;\r\n\tx-unix-mode=0644;\r\n\tname=\"my-csv-file.csv\"",
:data #object[ ... MimeBodyPart ... ]})
A lot of inspiration and ideas comes from these repositories:
Useful Java docs:
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close