Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to fetch email body #95

Open
kushaldexati opened this issue Jul 3, 2020 · 1 comment
Open

How to fetch email body #95

kushaldexati opened this issue Jul 3, 2020 · 1 comment

Comments

@kushaldexati
Copy link

I am able to fetch message subject but I cannot fetch what's written in thr body of email. Plz help in swift

@janek
Copy link

janek commented Feb 16, 2021

I had some issues, too, but was able to get it to work with the following snippet:
(thanks in part to #87)

let postal = Postal(configuration: .init(hostname: "imap.myemailprovider.de", port: 993, login: "[email protected]", password: .plain("mypassword"), connectionType: .tls, checkCertificateEnabled: false))
postal.connect { result in
    switch result {
    case .success:
        postal.fetchLast("INBOX", last: 1, flags: [ .body, .fullHeaders ], onMessage: { message in
                message.body?.allParts.forEach { part in
                    let data = part.data?.decodedData
                    print(String(decoding: data!, as: UTF8.self))
                }
            }, onComplete: { error in
                if let error = error {
                    print("error: \(error)")
                } else {
                    print("done")
                }
        })
    case .failure(let error):
        print("error: \(error)")
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants