标签: mailcore

在Swift中发送Mailcore2普通电子邮件

我最近将MailCore2合并到了我的Objective-C项目中,并且它运行得很好.现在,我正在将应用程序中的代码转换为Swift.我已成功将MailCore2 API导入到我的swift项目中,但我没有看到如何将以下工作的Objective-C代码转换为Swift代码的文档(Google搜索,libmailcore.com,github):

MCOSMTPSession *smtpSession = [[MCOSMTPSession alloc] init];
smtpSession.hostname = @"smtp.gmail.com";
smtpSession.port = 465;
smtpSession.username = @"matt@gmail.com";
smtpSession.password = @"password";
smtpSession.authType = MCOAuthTypeSASLPlain;
smtpSession.connectionType = MCOConnectionTypeTLS;

MCOMessageBuilder *builder = [[MCOMessageBuilder alloc] init];
MCOAddress *from = [MCOAddress addressWithDisplayName:@"Matt R"
                                              mailbox:@"matt@gmail.com"];
MCOAddress *to = [MCOAddress addressWithDisplayName:nil 
                                            mailbox:@"hoa@gmail.com"];
[[builder header] setFrom:from];
[[builder header] setTo:@[to]];
[[builder header] setSubject:@"My message"];
[builder setHTMLBody:@"This is a test message!"];
NSData * rfc822Data = [builder data];

MCOSMTPSendOperation *sendOperation = 
   [smtpSession sendOperationWithData:rfc822Data];
[sendOperation start:^(NSError *error) {
    if(error) {
        NSLog(@"Error sending …
Run Code Online (Sandbox Code Playgroud)

api objective-c mailcore mailcore2 swift

12
推荐指数
2
解决办法
9087
查看次数

如何在mailcore2中获取电子邮件正文

我试图从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 2822RFC 5322,但没有一个能够直接回答上述问题.

有人可以告诉我一个获取整个邮件正文的简单代码示例吗?

email imap objective-c ios mailcore

4
推荐指数
1
解决办法
4757
查看次数

在ios 8上使用MailCore2发送附件

我无法通过MailCore2发送附件.我可以使用MailCore for ios 8吗?能否请你为我提供正确的方法.我想在附件中发送docx,pdf,xls,png和jpeg文件

ios mailcore

3
推荐指数
1
解决办法
2093
查看次数

Mailcore 2错误"此服务器的证书无效." iOS版

我尝试使用以下代码从我的公司电子邮件中通过IMAP协议获取邮件:

MCOIMAPSession *session = [[MCOIMAPSession alloc] init];
[session setHostname:@"imap.mymail.com"];
[session setPort:993];
[session setUsername:@"accidbright@mymail.com"];
[session setPassword:@"password"];
[session setConnectionType:MCOConnectionTypeTLS];
MCOIMAPFetchMessagesOperation * fetchOperation = [session fetchMessagesByUIDOperationWithFolder:inboxFolder requestKind:MCOIMAPMessagesRequestKindHeaders uids:searchResult];
[fetchOperation start:^(NSError *error, NSArray *messages, MCOIndexSet *vanished) {
    if (error) {
        NSLog(@"Fetching all the message subjects error: %@!", error);
    } else {
        NSLog(@"Fetched all the messages subjects!");
    }
}];
Run Code Online (Sandbox Code Playgroud)

我得到错误:

Fetching all the message subjects error: Error Domain=MCOErrorDomain Code=4 
"The certificate for this server is invalid." UserInfo=0x7889ab0 
{NSLocalizedDescription=The certificate for this server is invalid.}!
Run Code Online (Sandbox Code Playgroud)

我知道,我们的邮件是使用域名证书签名的,因此在域外,它是未经验证的证书.但几乎所有使用邮件(fe …

email ios mailcore mailcore2

1
推荐指数
1
解决办法
1210
查看次数

标签 统计

mailcore ×4

ios ×3

email ×2

mailcore2 ×2

objective-c ×2

api ×1

imap ×1

swift ×1