我正在尝试从 iOS 中的 SKPSMTP 代码发送 HTML 电子邮件。现在,我只是发送纯文本,但我正在尝试稍微升级一下。我在下面包含了该代码。
我找不到任何文档。如何上传 HTML 文件并将其作为正文包含在内。此外,还有一个图像从与 HTML 文件相同的目录中加载,如果这对答案有影响的话。谢谢。
NSMutableString *emailBody = [NSMutableString stringWithFormat:@"Here's your code again, "];
[emailBody appendString:userCode];
SKPSMTPMessage *email = [[SKPSMTPMessage alloc] init];
email.fromEmail = @"me@gmail.com";
NSString *toEmail = [NSString stringWithFormat:@"%@", self.loginInput.text];
email.toEmail = toEmail;
email.relayHost = @"smtp.gmail.com";
email.requiresAuth = YES;
email.login = @"me@gmail.com";
email.pass = @"myPass";
email.subject = @"Your Validation Code";
email.wantsSecure = YES;
email.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
emailBody,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey, nil];
email.parts = [NSArray arrayWithObjects:plainPart, nil];
// Send it!
[email send];