Postal
Postal copied to clipboard
How to fetch email body
I am able to fetch message subject but I cannot fetch what's written in thr body of email. Plz help in swift
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)")
}
}