我正在尝试使用google smtp发送邮件。并附上图像,我的代码和我的错误。 我的代码: - (IBAction为)gonder:(ID)发送方{
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = @"fromme@gmail.com";
testMsg.toEmail = @"tome@hotmail.com";
testMsg.relayHost = @"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = @"myadress@gmail.com";
testMsg.pass = @"mypass";
testMsg.subject = @"had";
//testMsg.bccEmail = @"to@hotmail.com";
testMsg.wantsSecure = YES;
testMsg.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
@"FDDFAFAD",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
NSString *vcfPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"vcf"];
NSData *vcfData = [NSData dataWithContentsOfFile:vcfPath];
NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"test.vcf\"",kSKPSMTPPartContentTypeKey,
@"attachment;\r\n\tfilename=\"test.vcf\"",kSKPSMTPPartContentDispositionKey,[vcfData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart,nil];
[testMsg send];
和我的错误
在抛出'NSException'实例后终止调用
你能帮帮我吗?我需要在此代码中附加图像。答案 0 :(得分:0)
从示例代码开始:
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!