0
我正在構建一個應用程序接收電子郵件 我提取了電子郵件的主題,但我無法獲得正文電子郵件。 這裏是我的代碼如何使用郵件核心2獲取電子郵件的正文IOS Swift
let imapsession = MCOIMAPSession()
imapsession.hostname = "xxxx"
imapsession.port = 993
imapsession.username = "xxxx"
imapsession.password = "xxxx"
imapsession.connectionType = MCOConnectionType.TLS
let requestKind : MCOIMAPMessagesRequestKind = MCOIMAPMessagesRequestKind.Headers
let folder : String = "INBOX"
let uids : MCOIndexSet = MCOIndexSet(range: MCORangeMake(1, UINT64_MAX))
let fetchOperation : MCOIMAPFetchMessagesOperation = imapsession.fetchMessagesOperationWithFolder(folder, requestKind: requestKind, uids: uids)
fetchOperation.start { (err, msg, vanished) -> Void in
let msgs = msg as! [MCOIMAPMessage]
print("error from server \(err)")
for i in 0..<msgs.count
{
// Here i want the body of all emails fetched...
if let m = msgs[i].header.subject
{
print("\(i). \(m)")
}
}
}
我看到這個答案很好,但我無法理解
Fetch an email body in mailcore2 OSX with swift
所以請指導我這個
什麼是message.uid?我在哪裏申報?我將如何指定uid?好心的幫助我多一點... 感謝預期。 –
message.uid是引用電子郵件的唯一編號,不會隨着時間而改變 – 2016-04-15 10:07:56
如何將值分配給uid以指定我需要的電子郵件地址? –