abb*_*ood 4 email imap objective-c ios mailcore
我试图从mailcore迁移到mailcore2.以前在mailcore中,获取正文结构就像[msg fetchBodyStructure]msg是CTCoreMessage对象一样简单.
使用mailcore2,事情似乎更复杂.在MCOIMAPSession的获取消息体的文档中,我们有:
MCOIMAPFetchContentOperation * op =
[session fetchMessageAttachmentByUIDOperationWithFolder:@"INBOX"
uid:[message uid]
partID:"1.2"
encoding:[part encoding]];
[op start:^(NSError * error, NSData * partData) {
}];
Run Code Online (Sandbox Code Playgroud)
我完全不知道这1.2应该是指什么.作者将用户引用到RFC 822,RFC 2822和RFC 5322,但没有一个能够直接回答上述问题.
有人可以告诉我一个获取整个邮件正文的简单代码示例吗?
Gal*_*ank 17
我不确定为什么人们会使事情变得复杂:这就是你用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];
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4757 次 |
| 最近记录: |