Skip to content

Latest commit

Β 

History

History
74 lines (57 loc) Β· 2.72 KB

File metadata and controls

74 lines (57 loc) Β· 2.72 KB

GMime.jl

Stable Dev Build Status Coverage Registry

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

  • gmime – Official library repository.
  • gmime_jll.jl – Julia wrapper for gmime.
  • Enable IMAP support in your email provider’s settings. See this Gmail guide.
  • Generate an app-specific password for your email account. See details here.

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.