Awesome
GMime.jl
GMime is a convenient wrapper around the GMime library for parsing email messages in Julia. It can extract sender, recipient, date, body text, attachments and other email information.
Installation
To install GMime, simply use the Julia package manager:
] add Gmime
Usage
Here's a small example of how to parse content from an email body:
using GMime
using EasyCurl
# Fetch the email data from an IMAP server
response = imap_request(
"imaps://imap.gmail.com:993",
get(ENV, "IMAP_USER", ""),
get(ENV, "IMAP_PASSWORD", ""),
mailbox = "INBOX",
path = "MAILINDEX=993"
)
# Extract the raw email body
data = imap_body(response)
# Parse the email using GMime
julia> email = parse_email(data)
š§ Email:
š¤ From: Broker Support <support@broker.com>
š„ To: Portfolio Manager <pm@hedgefund.com>
š Date: 2024-08-06T17:34:04
š Attachments:
1. š Attachment:
š Name: CashFlowReport_Q3_2024.pdf
š ļø Encoding: base64
š· Mime type: application/pdf
š Size: 18000 bytes
2. š Attachment:
š Name: ClosedPositions_Summary_2024-08-06.csv
š ļø Encoding: base64
š· Mime type: text/csv
š Size: 250000 bytes
3. š Attachment:
š Name: DailyTransaction_2024-08-06.csv
š ļø Encoding: base64
š· Mime type: text/csv
š Size: 12800 bytes
Useful Links
- Turn on the IMAP support at email provider cabinet. See this Gmail guide.
- Create an app-specific password for your email. See here for details.
Contributing
Contributions to GMime are welcome! If you encounter a bug, have a feature request, or would like to contribute code, please open an issue or a pull request on GitHub.