使用SKPSMTPMessage发送的电子邮件附件在iOS邮件客户端中显示为联系人
我已经使用这个有用的库测试了发送附件的代码: 电子邮件似乎发送正确,当我通过hotmail或gmail客户端查看时,我看到了jpeg图像。但是,当我通过iOS邮件客户端查看同一封电子邮件时,附件显示为“联系人”,单击此按钮,我可以选择将文件另存为新联系人 我尝试从hotmail发送带有jpeg附件的电子邮件,当我这样做时,它会正确地显示在iOS客户端中 有人知道这是代码还是iOS弄错了吗使用SKPSMTPMessage发送的电子邮件附件在iOS邮件客户端中显示为联系人,ios,email,smtp,Ios,Email,Smtp,我已经使用这个有用的库测试了发送附件的代码: 电子邮件似乎发送正确,当我通过hotmail或gmail客户端查看时,我看到了jpeg图像。但是,当我通过iOS邮件客户端查看同一封电子邮件时,附件显示为“联系人”,单击此按钮,我可以选择将文件另存为新联系人 我尝试从hotmail发送带有jpeg附件的电子邮件,当我这样做时,它会正确地显示在iOS客户端中 有人知道这是代码还是iOS弄错了吗 //the guts of the message. SKPSMTPMessage *testMsg =
//the guts of the message.
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = @"aname@gmail.com";
testMsg.toEmail = @"aname@gmail.com";
testMsg.relayHost = @"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = @"aname@gmail.com";
testMsg.pass = @"password";
testMsg.subject = @"The message subject";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
// Only do this for self-signed certs!
// testMsg.validateSSLChain = NO;
testMsg.delegate = self;
//email contents
NSDate* now = [NSDate date];
NSString * bodyMessage = [NSString stringWithFormat:@"The message body"];
// email image if it exists
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/file.jpeg"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableArray* parts = [[NSMutableArray alloc] init];
// add plain part
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
bodyMessage ,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
[parts addObject: plainPart];
// add attachments
NSData *attachmentData = [NSData dataWithContentsOfFile:jpgPath];
NSString *directory = @"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"file.jpeg\"";
NSString *attachment = @"attachment;\r\n\tfilename=\"file.jpeg\"";
NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys:
directory,kSKPSMTPPartContentTypeKey,
attachment,kSKPSMTPPartContentDispositionKey,
[attachmentData encodeBase64ForData],kSKPSMTPPartMessageKey,
@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
[parts addObject: image_part];
testMsg.parts = parts;
[testMsg send];
尝试改变
NSString *directory = @"text/directory;...
到
我希望这对你有用
Steffen这有用吗?我正在尝试将jpeg图像添加到电子邮件中。似乎对我不起作用。我试图用后台线程发送一封电子邮件,但最终还是被拒绝了。我求助于使用代理服务器来传递消息。
NSString *directory = @"text/jpeg;...