I'm using the Postal is a swift framework providing simple access to common email providers. I have seen demo about it, but I don't know how I can have my text content that I need from a FetchResult? Thanks. This code fetch mail from mail server:
self.postal.connect(timeout: Postal.defaultTimeout) { (result) in
switch result {
case .Success():
self.postal.fetchLast("INBOX", last: UInt(number), flags: flags, onMessage: { (message) in
message.body?.allParts.flatMap({ (singlePart) -> String? in
let textMail = String.init(data: (singlePart.data?.rawData)!, encoding: NSUTF8StringEncoding)
print(textMail)
return textMail
})
}, onComplete: { (error) in
if let error = error {
print(error)
}else {
}
})
break
case .Failure(let error):
print(error)
}
}
and result log: Optional("\u{1B}$B$3$N%\"%W%j$O!\"0lEY\u{1B}(BiBeacon\u{1B}$B$r