MailCore2,在init MCOSMTPSession,MCOMessageBuilder和MCOAddress

时间:2015-05-25 10:27:50

标签: ios objective-c xcode mailcore2

我是xcode的新手,现在使用Xcode 6.3.2创建一个带MailCore2的应用程序来发送电子邮件。每次我为MCOSMTPSessionMCOMessageBuilderMCOAddress创建变量时,此变量始终为'nil'。为了加快速度,我将在这里复制我的代码。

MCOSMTPSession *smtpSession = [[MCOSMTPSession alloc] init];
smtpSession.hostname = smtpServer;
smtpSession.port = (unsigned int)smtpPort;
smtpSession.username = fromAddress;
smtpSession.password = fromPass;
smtpSession.connectionType = MCOConnectionTypeTLS;

MCOMessageBuilder *builder = [[MCOMessageBuilder alloc] init];
MCOAddress *from = [MCOAddress  addressWithMailbox:fromAddress];
NSMutableArray *toAddresses = [[NSMutableArray alloc] init];
MCOAddress *to = [MCOAddress addressWithMailbox:toAddress];
[toAddresses addObject:to];
[[builder header] setFrom:from];
[[builder header] setTo:toAddresses];
[[builder header] setSubject:@"[Biz Cards App]"];
[builder setTextBody:[self.txtNotes text]];

NSData * rfc822Data = [builder data];

smtpSession,builder,from和to init在我执行init之后总是没有。在这种情况下,有谁可以帮助我?任何帮助将不胜感激。谢谢。

通过使用此Library将MailCore2添加为静态库,修复了上述问题。

现在我在访问时遇到错误

NSData * rfc822Data = [builder data];

MCOMessageBuilderError

我没有进一步的线索,因为日志没有显示任何内容。谢谢你的帮助。

0 个答案:

没有答案