要在iOS中发送电子邮件,其中包含电子邮件正文中的图像和文字 [英] Want to send a email with images and text in the body of email in iOS

查看:159
本文介绍了要在iOS中发送电子邮件,其中包含电子邮件正文中的图像和文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS中,要使用邮件作曲者发送带有嵌入图像和文本的电子邮件正文中的电子邮件(而不是附件)。任何人都可以帮助?

In iOS, want to send a email with embedded images and text in the body of the email ( not attachment) using mail composer. Can anybody help ?

推荐答案

您可以使用HTML内容与img标签进行此操作。您可以使用以下代码:

You can use the HTML content with img tag for doing this. You can use the following code:

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];

这篇关于要在iOS中发送电子邮件,其中包含电子邮件正文中的图像和文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆