问题描述
我尝试从迁移到。以前在mailcore中,获取一个body结构就像 [msg fetchBodyStructure]
一样简单,其中msg是一个对象。
I've trying to migrate from mailcore to mailcore2. Previously in mailcore, fetching a body structure was as simple as [msg fetchBodyStructure]
where msg is a CTCoreMessage object.
使用mailcore2,事情似乎更复杂。在,和但是他们都没有一个直截了当的答案。
I have absolutely no idea what this 1.2
is supposed to refer to. The authors refer the users to RFC 822, RFC 2822, and RFC 5322 but none of them has a straightforward answer to the above.
有人可以给我一个简单的代码示例来获取整个邮件正文吗?
Can someone please show me a simple code sample of fetching an entire message body?
推荐答案
我不知道为什么人们会使事情变得复杂:
这是你如何使用MailCore2获取电子邮件正文:
I'm not sure why people complicate things:this is how you fetch email body with MailCore2:
MCOIMAPSession *session = [[MCOIMAPSession alloc] init];
[session setHostname:@"imap.gmail.com"];
[session setPort:993];
[session setUsername:[UICKeyChainStore stringForKey:@"username"]];
[session setPassword:[UICKeyChainStore stringForKey:@"password"]];
[session setConnectionType:MCOConnectionTypeTLS];
MCOIMAPFetchContentOperation *operation = [session fetchMessageByUIDOperationWithFolder:@"INBOX" uid:message.uid];
[operation start:^(NSError *error, NSData *data) {
MCOMessageParser *messageParser = [[MCOMessageParser alloc] initWithData:data];
NSString *msgHTMLBody = [messageParser htmlBodyRendering];
[webView loadHTMLString:msgHTMLBody baseURL:nil];
}];
这篇关于如何在mailcore2中获取邮件正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!