我的应用中嵌入了HTML,我希望能够在应用内发送电子邮件。我已经设置了以下代码,它将通过电子邮件发送电子邮件中的文本,但不附加嵌入其中的图像。我相信这是因为没有正确设置baseURL,但我不确定如何为emailBody做到这一点。有什么想法吗?
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"Thanks" ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"A prayer gift of thanks to you"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"friend@example.com"];
[picker setToRecipients:toRecipients];
// Fill out the email body text
NSString *emailBody = htmlString;
[picker setMessageBody:emailBody isHTML:YES];
答案 0 :(得分:0)
NSString *emailBody = @"<html><body>";
emailBody = [emailBody stringByAppendingString:@"<img src='http://icons.iconarchive.com/icons/arrioch/halloween/512/devil-icon.png' width = '64' height='64'/>"];
emailBody = [emailBody stringByAppendingString:@"<br>"];
emailBody = [emailBody stringByAppendingFormat:@"%@",NSLocalizedString(@"My text", @"")];
emailBody = [emailBody stringByAppendingString:@"<br>"];
emailBody = [emailBody stringByAppendingString:@"</body></html>"];
[picker setMessageBody:emailBody isHTML:YES];