想要在iOS中的电子邮件正文发送图像和文字的电子邮件
在iOS中,要使用邮件编辑器在电子邮件正文(不是附件)中发送带有embedded式图像和文本的电子邮件。 任何人都可以帮忙吗?
您可以使用带有img标签的HTML内容来做到这一点。 您可以使用下面的代码:
NSMutableString *imgContent = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain]; UIImage *imageData = [UIImage imageNamed:@"Midhun.png"]; NSData *imageDataInBase64 = [NSData dataWithData:UIImagePNGRepresentation(imageData)]; NSString *base64String = [imageDataInBase64 base64EncodedString]; [imgContent appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",base64String]]; [imgContent appendString:@"</body></html>"]; MFMailComposeViewController *emailWin = [[MFMailComposeViewController alloc] init]; [emailWin setMessageBody:imgContent isHTML:YES];
MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc] init];
[mailComposer setMailComposeDelegate:self]; if ([MFMailComposeViewController canSendMail]) { [mailComposer setToRecipients:[NSArray arrayWithObjects:@"kmlshyadav6@gmail.com", nil]]; [mailComposer setSubject:@"Awesome Image(ur message or subject)"]; [mailComposer setMessageBody:@"Hey,\n\nCheck out this awesome image!\n\n" isHTML:NO]; [mailComposer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; UIImage *lion = imageView.image; NSData *lionData = UIImageJPEGRepresentation(lion, 1); [mailComposer addAttachmentData:lionData mimeType:@"image/jpeg" fileName:@"01-Mac-OS-X-Lion.jpg"]; } [self presentModalViewController:mailComposer animated:YES]; [mailComposer release]; } else { [mailComposer release]; }
- 如何使用UIActivityItemProvider设置邮件主题
- 如何closuresMFMailComposeViewController?
- 我们可以从iPhone的联系人列表中访问emailids吗?
- 邮件和消息不会从警报视图中消失
- HTML电子邮件丢失在iPhone上太长时间格式化
- iOS MFMailComposeViewController和从联系人卡获取用户名
- MFMailComposeViewController电子邮件到iPhone的字段限制40
- Swift尝试呈现其视图不在窗口层次结构中的UIAlertController(在TWTRShareEmailViewController之后呈现)
- 在firebase,swift项目中编辑信息