这个过程正在发送电子邮件,它工作正常,但框架希望电子邮件的正文是一个 NSArray。所以我尝试将 NSString 转换为 NSDictionary 以包含在 NSArray 中:
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:kSKPSMTPPartContentTypeKey,
message,kSKPSMTPPartMessageKey,kSKPSMTPPartContentTransferEncodingKey, nil];
然后我在这里实现:
smtpTestMessage.parts = [NSArray arrayWithObject:plainPart];
总的来说,这是我的代码:
NSLog(@"Start eMail");
SKPSMTPMessage *smtpTestMessage = [[SKPSMTPMessage alloc] init];
smtpTestMessage.fromEmail = @"***@gmail.com";
smtpTestMessage.toEmail = @"***@yahoo.com";
smtpTestMessage.relayHost = @"smtp.gmail.com";
smtpTestMessage.requiresAuth = YES;
smtpTestMessage.login = @"***@gmail.com";
smtpTestMessage.pass = @"***";
smtpTestMessage.subject = @"***";
smtpTestMessage.wantsSecure = YES;
smtpTestMessage.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:kSKPSMTPPartContentTypeKey,
message,kSKPSMTPPartMessageKey,kSKPSMTPPartContentTransferEncodingKey, nil];
smtpTestMessage.parts = [NSArray arrayWithObject:plainPart];
[NSString stringWithFormat:@"%@",message];
[smtpTestMessage send];
NSLog(@"sent");
但可悲的是,当我运行应用程序时,电子邮件进入最后阶段......然后应用程序终止说
2013-10-15 00:43:50.512 BullyBox[3662:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x2f61ae8b 0x399156c7 0x2f5540cb 0x2f556749 0xc77f3 0x31dd555f 0x31dd54fb 0x31dd54cb 0x31dc10f3 0x31dd4f13 0x31dd4bdd 0x31dcfc09 0x31da4f59 0x31da3747 0x2f5e5f27 0x2f5e53ef 0x2f5e3bdf 0x2f54e541 0x2f54e323 0x342852eb 0x31e051e5 0xc91b5 0x39e0eab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
编辑
现在我不断收到错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString appendString:]: nil argument'
任何帮助是极大的赞赏!感谢您阅读本文!xD <3