iPhone SDK将图像添加到电子邮件正文? [英] iPhone SDK Add Image to the Body of an Email?

查看:182
本文介绍了iPhone SDK将图像添加到电子邮件正文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当邮件应用程序打开时,是否有人知道如何使用电子邮件正文中的图像。任何人都可以帮忙?

I was wondering if anyone knew how to use an image in the body of an email when the mail app is opened. Can anyone help?

提前感谢Kieran。

Thanks in advance Kieran.

推荐答案

你可以使用base64编码在邮件正文中附加图像

you can attach image in mail body using base64 encoding

MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];

NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
NSString *imageStr = [imageData base64EncodingWithLineLength:[imageData length]];

NSString *htmlStr = [NSString stringWithFormat:@".....<img src='data:image/jpeg;base64,%@'>.......",imageStr];

[mailComposer setMessageBody:htmlStr isHTML:YES];
[self presentModalViewController:mailComposer animated:YES];
        [mailComposer release];

这篇关于iPhone SDK将图像添加到电子邮件正文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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