ios 如何在 MFMailComposeViewController 的 MailComposer Sheet 中添加 UIImage

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1527351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:29:55  来源:igfitidea点击:

How to add a UIImage in MailComposer Sheet of MFMailComposeViewController

iphoneiosattachmentmfmailcomposeviewcontroller

提问by rkb

I want to insert a UIImages inside the compose sheet of an MFMailComposerViewController.

我想在UIImage一个MFMailComposerViewController.

Please note I don't want to attach them, but I want to place them in a table using HTML code which will be the part of the email body.

请注意,我不想附加它们,但我想使用 HTML 代码将它们放在表格中,这将成为电子邮件正文的一部分。

回答by Mike

Back again with a new answer. I'm still leaving my previous code up though, because I'm still not convinced that there's not a way to make use of it. I'll keep at it myself. The following code DOES work. Mustafa suggests base64 encoding the images, and says that they only work Apple to Apple, but that's not actually true. Base64 encoding does work with most mail clients now (IE previously didn't support it, but now it is supported for images up to a certain size, though I'm not sure exactly what the size is). The problem is that mail clients like Gmail would strip out your image data, but there's a simple workaround for that... just putting <b> and </b>tags around your <img ...>tag is all you need to do to keep it from getting stripped out. In order to get an image into your email, you need to get a base64 encoder into your project. There are several out there (mostly C though), but the simplest ObjC one I found was called NSData+Base64 by Matt Gallagher(I took the "+" out of the name after copying it in because it gave me problems). Copy the .h and .m files into your project and be sure to #import the .h file where you plan on using it. Then code like this will get an image into your email body...

带着新的答案再次回来。我仍然保留我以前的代码,因为我仍然不相信没有办法使用它。我自己会坚持的。以下代码确实有效。Mustafa 建议对图像进行 base64 编码,并表示它们仅适用于 Apple 对 Apple,但实际上并非如此。Base64 编码现在确实适用于大多数邮件客户端(IE 以前不支持它,但现在它支持特定大小的图像,尽管我不确定大小是多少)。问题是像 Gmail 这样的邮件客户端会删除你的图像数据,但有一个简单的解决方法......只需<b> and </b>在你的周围放置标签<img ...>标签是您需要做的一切,以防止它被剥离。为了在您的电子邮件中添加图像,您需要在您的项目中使用 base64 编码器。有几个(尽管主要是 C),但我发现的最简单的 ObjC被 Matt Gallagher称为NSData+Base64(我在复制它后去掉了名称中的“+”,因为它给我带来了问题)。将 .h 和 .m 文件复制到您的项目中,并确保在您计划使用它的地方 #import .h 文件。然后像这样的代码会将图像放入您的电子邮件正文...

- (void)createEmail {
//Create a string with HTML formatting for the email body
    NSMutableString *emailBody = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain];
 //Add some text to it however you want
    [emailBody appendString:@"<p>Some email body text can go here</p>"];
 //Pick an image to insert
 //This example would come from the main bundle, but your source can be elsewhere
    UIImage *emailImage = [UIImage imageNamed:@"myImageName.png"];
 //Convert the image into data
    NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)];
 //Create a base64 string representation of the data using NSData+Base64
    NSString *base64String = [imageData base64EncodedString];
 //Add the encoded string to the emailBody string
 //Don't forget the "<b>" tags are required, the "<p>" tags are optional
    [emailBody appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",base64String]];
 //You could repeat here with more text or images, otherwise
 //close the HTML formatting
    [emailBody appendString:@"</body></html>"];
    NSLog(@"%@",emailBody);

 //Create the mail composer window
    MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init];
    emailDialog.mailComposeDelegate = self;
    [emailDialog setSubject:@"My Inline Image Document"];
    [emailDialog setMessageBody:emailBody isHTML:YES];

    [self presentModalViewController:emailDialog animated:YES];
    [emailDialog release];
    [emailBody release];
}

I've tested this on the iPhone and sent lovely image embedded emails to myself on Yahoo, my personal website, and my MobileMe. I don't have a Gmail account, but the Yahoo worked perfectly, and every source I've found says that the bold-tags are all you need to make it work. Hope this helps all!

我已经在 iPhone 上对此进行了测试,并在 Yahoo、我的个人网站和我的 MobileMe 上向自​​己发送了嵌入可爱图片的电子邮件。我没有 Gmail 帐户,但 Yahoo 运行良好,我发现的每个来源都说粗体标签是让它工作所需的全部内容。希望这对大家有帮助!

回答by Ramin

There are two ways to do this, depending on where the images are stored:

有两种方法可以做到这一点,具体取决于图像的存储位置:

If the images are out on a server, then just include HTML <img>tags with the source URL set to the remote image. The user previewing the mail message is shown the image during composition and the receiver sees it when they open the message (unless they've disabled default image loading).

如果图像在服务器上,则只需包含 HTML<img>标记,并将源 URL 设置为远程图像。预览邮件消息的用户在撰写期间会显示图像,接收者在打开邮件时会看到它(除非他们禁用了默认图像加载)。

If the images are on the phone you could include them as 'inline' images. There are two steps to this. First you have to attach all the images you want to use as multi-part MIME attachments and they will need to be assigned a 'content ID' (aka cid), a filename, and Content-Dispositionset to inline. Inside your HTML message body you can reference them like so:

如果图像在手机上,您可以将它们包含为“内嵌”图像。这有两个步骤。首先,您必须附加要用作多部分 MIME 附件的所有图像,并且需要为它们分配一个“内容 ID”(又名cid)、一个文件名,并Content-Disposition设置为inline. 在 HTML 消息正文中,您可以像这样引用它们:

<img src="cid:{messageid}/image.png" alt="My image" />

The bad news is, the standard iPhone mail composer mechanism doesn't allow adding this additional data to attachments. The second thing is to mark the email as having an "alternative" MIME content-type. Again, the mail composer doesn't let you do that.

坏消息是,标准的 iPhone 邮件编写器机制不允许将此附加数据添加到附件中。第二件事是将电子邮件标记为具有“替代”MIME 内容类型。同样,邮件编辑器不允许您这样做。

The way around this is to either compose the message yourself then send it off to the mail server directly via SMTP, or have a server proxy do it for you via an SMTP relay. If you decide to go this way you might want to check out skpsmtpmessageon Google code or a service like AuthSMTP.

解决这个问题的方法是要么自己编写邮件,然后直接通过 SMTP 将其发送到邮件服务器,要么让服务器代理通过 SMTP 中继为您完成。如果您决定采用这种方式,您可能需要查看Google 代码上的skpsmtpmessageAuthSMTP 之类的服务。

Once the user receives this message, however, they see a self-contained HTML message with all the inline images right there. But it's a lot of hassle to set up. The first method (putting images on server) is by far the easier way to go.

但是,一旦用户收到此消息,他们就会看到一个包含所有内嵌图像的自包含 HTML 消息。但是设置起来很麻烦。第一种方法(将图像放在服务器上)是迄今为止更简单的方法。

回答by Arie Litovsky

For iOS 3.0 and later, please see this: Attaching an image to an email?

对于 iOS 3.0 及更高版本,请参阅:将图像附加到电子邮件?

Example:

例子:

UIImage * image = [UIImage imageWithContentsOfFile:imagePath];
[composer addAttachmentData:UIImageJPEGRepresentation(itemImage, 1) mimeType:@"image/jpeg" fileName:@"MyFile.jpeg"];

回答by Mustafa

Maybe this'll work for you:

也许这对你有用:

How to Embedd UIImage into a Mail Composer message body

如何将 UIImage 嵌入到 Mail Composer 邮件正文中

Here's what it says:

这是它所说的:

Basically, you convert your image to base64 (the base64 attached below have to be shorten cause of the message length limit, so it's not a valid image) string and embed in the image tag. I remember I've stop working on this is because the embedded image(s) are only viewable from iPhone to another iPhone, I remember testing it with Gmail, our work Outlook client with no luck display the image, when I view source the data is there. So I don't think is the so much of a spam filter issue but email clients are just smarter. While I was research this, I actually found that this is how many spammers to blast out emails with image only info so it by passes the spam filter. Damn spammers, I was going to use it for good cause but since it was pretty much useless when I found out that most mail client won't display the image. For what it's worth, here is the code.

基本上,您将图像转换为 base64(下面附加的 base64 必须是由于消息长度限制而缩短的原因,因此它不是有效图像)字符串并嵌入到图像标签中。我记得我已经停止研究这是因为嵌入的图像只能从 iPhone 到另一台 iPhone 可见,我记得用 Gmail 测试它,我们的工作 Outlook 客户端没有运气显示图像,当我查看源数据时在那儿。所以我不认为垃圾邮件过滤器问题如此严重,但电子邮件客户端更聪明。当我在研究这个时,我实际上发现这是有多少垃圾邮件发送者用图像信息来发送电子邮件,以便它通过垃圾邮件过滤器。该死的垃圾邮件发送者,我打算使用它是有充分理由的,但是当我发现大多数邮件客户端不会显示图像时,它几乎毫无用处。为了什么'

NSString *eMailBody = @"<html>Just convert your image file to base64 to embed into the email<img src="data:image/gif;base64,R0lGODlhFAFuAPcAAPf39//7/+fn59bT1u/r787Lzq0UAN7b3hhFrRhJtRA0hBA8lMYYALWytffz94wQAMa+vb26vRhNxufj5+/v78bDxvfz772+vcbHxghRCM7PzggkYyFZ1tYkCNbX1hhRzpyenO+6AN7f3gBlANauAGOW7zFl1kp95wg8pbW2tZyanHOi797f5zlx3msMAAB9CP/PAL22va2mraWipedJMSlRtf91Y72WAFqK76WmpRBFta2qrcaeAK2urfdpUuc8If39/e9ZQmPTY94wGFrLWrUkEISq9/n5+ZR5ABCWGLWOAIRpAGNRAClJlK2GAL0sGGssITG2OaWCAK3H9848KaW+762qpcbX/73jvWN5pGvTc/eGc//vCFppfIwgEJRBMYSGlPeWhJSSjHN5jMaSjKWmrb3P787V1ilBa4R9c9nXy+rq6ntNQu/y95Su3svO1kphlISa1t7b1vf7/3uGraWGexdAmoySlDm6QrWyraWqrRiiIWtpa0LDStrl/1JtrcbHzpxlWntlUklVcztZk3vbhISStfffWufr786upVmB1ta2taW21tLS0ve6rd7j5zlhtfemnJSetefn78LCw7W2vdnZ2bVFMf/3//f3/8Z1a9bb59bb3eHh4a2WjM7HxoR1OSGqKbW6xvT09JyGQrXD3v/r5+fk3s7rzufb3q2ytffXKbWiY6inp1p1WrWmjP/LxnOOzsC/v+/n56qSMffXzr2eEP/3hPHx8f//987T57m4ubVZShk5f97LjO/HKQ03ks7DpdZlWv/vMd7LxqWuvefr/86uKd66QgwyhcnJyf/ztbKxsrWqpe/37//z7///75zTpf/397Szsvfn1ozLjO/jlN7v3qWko62OEO/r5//73tbX3vf37wotd1qqYxlNvYyujN7X1qKgoHuWe5KUmkKOQhZKvildMRh5IZqZmcXEwZ2amaajoNfU0QMaTAsiV5STlSo+bZibpSti2puZl5u28pGs5pqbn9Hd8/fr94WFi7i1sBguYfP09v///ywAAAAAFAFuAAAI/wD/CRxIsKDBgwgTKlzIsKHDhxAjSpxIsaLFixgzatzIsaPHjyBDihxJsqTJkyhTqlzJsqXLlzBjypxJs6bNmzhz6tzJs6fPn0CDCh1KtKjRo0iDYinEtJAWLUSIfJv6DVFShnOMXTEzpYrXKlPMXDGW6apZhli0CHmqtk+oJC9ejDDH6azBTGaMKDLBQUKCvzoC/5XAwcSJElV0UbB71lk0PFH6CGmqxS3cuZgyAwhw1tiUEiY+CEZBunTpwR9SfyisiNGmzYyNYqlWLZrtak6JRLmcoQKBCQQswEZ6ZcUJDn0RoFiwoAkhOH/+wCHURDkKHRIII0e+uoWbSbGRYv/SFy0qnj1yM6ArUEDDAQEOOBu9UqIF3xrMCWWRBGiAnP8eqKEBBpVIkgUhyg22nWocxKJLeEMBYIEAqVSD"></html>";

NSString *encodedBody = [eMailBody stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *urlString = [NSString stringWithFormat:@"mailto:[email protected]?subject=ImageTest&body=%@", encodedBody];
NSURL *url = [[NSURL alloc] initWithString:urlString];
[[UIApplication sharedApplication] openURL:url];

回答by Mike

(Unfortunately the following method doesn't work, but I'm leaving this post because the image URL path conversion string example is really helpful for other cases where you need HTML filepaths in your code. Please see my post on Base64Encoding for a way that does work.)

(不幸的是,以下方法不起作用,但我要离开这篇文章,因为图像 URL 路径转换字符串示例对于在代码中需要 HTML 文件路径的其他情况非常有帮助。请参阅我关于 Base64Encoding 的帖子确实有效。)

I ran into this issue myself, and I found a way that works. You CAN get the images to appear inline by using the full filepath to the image.

我自己遇到了这个问题,我找到了一种有效的方法。您可以使用图像的完整文件路径使图像内联显示。

It takes a little conversion on your part, but use the normal methods for obtaining your app's directories (NSString *path = [[NSBundle mainBundle] resourcePath], etc...), then convert the string to a literal URL. For example, the "path" string returned above will contain something like "/Users/Me/Library/Application Support/iPhone Simulator/3.2/Applications/25ADA98D-8DF4-4344-8B78-C18BC757EBDC/MyEmailingApplication.app".

您需要进行一些转换,但使用常规方法获取应用程序的目录(NSString *path = [[NSBundle mainBundle] resourcePath], etc...),然后将字符串转换为文字 URL。例如,上面返回的“路径”字符串将包含类似“/Users/Me/Library/Application Support/iPhone Simulator/3.2/Applications/25ADA98D-8DF4-4344-8B78-C18BC757EBDC/MyEmailingApplication.app”的内容

You'll need to make this string into

你需要把这个字符串变成

"file:///Users//Me//Library//Application%20Support//iPhone%20 Simulator//3.2//Applications//25ADA98D-8DF4-4344-8B78-C18BC757EBDC//MyEmailingApplication.app//"

" file:///Users//Me//Library//Application%20Support//iPhone%20 Simulator//3.2//Applications//25ADA98D-8DF4-4344-8B78-C18BC757EBDC//MyEmailingApplication.app//"

and then you can add your image filenames to the end. (this example points into the app resources, but the same applies for the tmp and documents directories).

然后您可以将图像文件名添加到末尾。(此示例指向应用程序资源,但同样适用于 tmp 和文档目录)。

You can do this string conversion with a combination of [NSString stringWithFormat:@"file:///%@//%@",path,myImageName]

您可以使用以下组合进行此字符串转换 [NSString stringWithFormat:@"file:///%@//%@",path,myImageName]

after using [path stringByReplacingOccurencesOfString:@"/" withString:@"//"]

使用后 [path stringByReplacingOccurencesOfString:@"/" withString:@"//"]

to fix the forward-slashes in "path", and

修复“路径”中的正斜杠,以及

[path stringByReplacingOccurencesOfString:@" " withString:@"%20"]

[path stringByReplacingOccurencesOfString:@" " withString:@"%20"]

to make the spaces HTML friendly. Now you can use this literal URL in your HTML encoded email body, like img src=\"",pathToMyImage,"\"

使空格 HTML 友好。现在,您可以在 HTML 编码的电子邮件正文中使用此文字 URL,例如 img src=\"",pathToMyImage,"\"

The example looks like a lot of work, but actually once you get it setup, it's not hard at all, and it works like a charm :-) Good luck!

该示例看起来需要做很多工作,但实际上一旦您设置好它,它就一点也不难,而且效果很好:-) 祝您好运!

回答by Tib

I tried the Mike's answerworks perfect inside the MFMailComposerViewController, but unfortunately not with most of the emails clients. Since I really need to send some email content with UIImage embedded, here's what I've done:

我试过Mike 的答案MFMailComposerViewController. 由于我确实需要发送一些嵌入 UIImage 的电子邮件内容,因此我所做的是:

  1. I kept the Mike's answercode to generate my HTML page with UIImage
  2. I've created an UIWebViewpresenting this page, with [yourwebview loadHTMLString:@"yourHTMLString" baseURL:nil]
  3. IMPORTANT: I display this in an UIViewControlleras a Preview pagefor the user
  4. Then I generate a PDF from this UIWebView, thanks to AnderCover's method
  5. Finally, I add the created PDF as an attachement to the email with [mailComposerController addAttachmentData:yourPDFFileAsNSData mimeType:@"application/pdf" fileName:@"yourFileName.pdf"]
  1. 我保留了Mike 的答案代码来生成我的 HTML 页面UIImage
  2. 我已经创建了一个UIWebView展示这个页面,[yourwebview loadHTMLString:@"yourHTMLString" baseURL:nil]
  3. 重要提示:我将此显示在用户UIViewController预览页面
  4. 然后我由此生成了一个 PDF,这UIWebView要归功于AnderCover 的方法
  5. 最后,我将创建的 PDF 作为附件添加到电子邮件中 [mailComposerController addAttachmentData:yourPDFFileAsNSData mimeType:@"application/pdf" fileName:@"yourFileName.pdf"]

Ok, don't blame me, I know this is a lot of conversions and actions for just adding some images, but your HTML email structure remains the same with images embedded, and the final user will receive only one good-looking attachement.
The "dirty" part is that the PDF content is actually screenshots of the webview...Not really reusable.

好吧,别怪我,我知道这只是添加一些图像的大量转换和操作,但是您的HTML电子邮件结构保持不变,嵌入图像,最终用户只会收到一个好看的附件
“脏”部分是 PDF 内容实际上是 webview 的屏幕截图......不是真正可重用的。

回答by pratap shaik

  1. remove the image tag
  2. just take the removed image tag and display using uimage view
  1. 删除图像标签
  2. 只需取出删除的图像标签并使用 uimage 视图显示

I tried the above examples, but they are not working. Below you will find sample code that works 100%. But you need to check the image tag url.

我尝试了上面的示例,但它们不起作用。您将在下面找到 100% 有效的示例代码。但是您需要检查图像标签网址。

//remove  the img tag 

NSScanner *theScanner;
NSString *gt =nil;

theScanner = [NSScanner scannerWithString:emailBody];

while ([theScanner isAtEnd] == NO) {

    // find start of tag
    [theScanner scanUpToString:@"<img" intoString:NULL] ; 

    // find end of tag
    [theScanner scanUpToString:@">" intoString:&gt] ;


    emailBody = [emailBody stringByReplacingOccurrencesOfString:[ NSString stringWithFormat:@"%@>", gt] withString:@""];
    NSString *tt=[ NSString stringWithFormat:@"%@>", gt];
        NSLog(@"*********************%@",tt);
    st=tt;
        NSLog(@"*********************%@",st);
}
st =[st stringByReplacingOccurrencesOfString:@"<img src=\"" withString:@""];
st =[st stringByReplacingOccurrencesOfString:@"\"/>" withString:@""];
st =[st stringByReplacingOccurrencesOfString:@".png" withString:@""];
st =[st stringByReplacingOccurrencesOfString:@"\"align=\"left" withString:@""];
//"align="left
NSLog(@"*********************%@",st);



NSString *path1 = [[NSBundle mainBundle] pathForResource:[ NSString stringWithFormat:@"%@", st] ofType:@"png"];
NSData *myData1 = [NSData dataWithContentsOfFile:path1];
[picker addAttachmentData:myData1 mimeType:@"image/png" fileName:[ NSString stringWithFormat:@"%@", st]];

回答by Mike

EDIT: What you're about to read DOESN'T work (yet)! Check my other post on Base64 Encoding your image which DOES work.

编辑:您将要阅读的内容(还)行不通!查看我在 Base64 Encoding your image 上的其他帖子,它确实有效。

This one looks just fine in the email composition window, but the actual sent email doesn't include the pics (I just tested it on my phone). I mistakenly thought that the mail app would base64 encode the images itself (It does so for attached images). And, although it's a pain, you can get an email on the iPhone to insert multiple "flowed" inline images by going to your image folder, copying an image to the clipboard, going to your email, and pasting it where you want. You can write more text, save the email as a draft, and repeat the process with more images pasted into the same email. Send the email to yourself, then open it on your computer with Text Edit. You'll be able to see exactly the formatting that the email takes (including the base64 encoded images).

这个在电子邮件撰写窗口中看起来不错,但实际发送的电子邮件不包含图片(我只是在手机上测试过)。我错误地认为邮件应用程序会对图像本身进行 base64 编码(它对附加图像这样做)。而且,虽然这很痛苦,但您可以在 iPhone 上收到一封电子邮件,通过转到您的图像文件夹、将图像复制到剪贴板、转到您的电子邮件并将其粘贴到您想要的位置,从而在 iPhone 上插入多个“流动”内联图像。您可以编写更多文本,将电子邮件另存为草稿,然后将更多图像粘贴到同一电子邮件中,重复此过程。将电子邮件发送给自己,然后使用文本编辑在您的计算机上打开它。您将能够准确地看到电子邮件采用的格式(包括 base64 编码的图像)。

What strangely happens with my code below is that the text makes it into the email, but the images just disappear entirely (not even a dangling "broken" reference to them :-/ ). This makes me doubt that linking to the images on an external server would work. I'm going to continue working on this... I'm wondering if it will behave differently if I have the email launch in the mail app outside of my program. I'll keep coming back to update this as I figure more out... it just seems like this should be easier than Apple makes it :-/

我下面的代码奇怪的是,文本进入了电子邮件,但图像完全消失了(甚至没有对它们的悬空“损坏”引用:-/)。这让我怀疑链接到外部服务器上的图像是否可行。我将继续研究这个......我想知道如果我在我的程序之外的邮件应用程序中启动电子邮件,它的行为是否会有所不同。我会继续回来更新这个,因为我想出了更多……看起来这应该比苹果更容易:-/

This code is written for image files that you'd store in your "Documents" directory (so your app would have to be creating images that are stored there, and HTML code that references those images. For images that you have stored in the app bundle, use [[NSBundle mainBundle] resourcePath] for the initial path to the images).

此代码是为您将存储在“文档”目录中的图像文件编写的(因此您的应用程序必须创建存储在那里的图像,以及引用这些图像的 HTML 代码。对于您存储在应用程序中的图像bundle,使用 [[NSBundle mainBundle] resourcePath] 作为图像的初始路径)。

- (void)createEmailWithInlineImages {
//get app Documents directory
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsPath = [paths objectAtIndex:0];
//make spaces HTML friendly
    documentsPath = [documentsPath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
//make forward-slash into double-forward-slash for HTML file-URL comapatibility
    documentsPath = [documentsPath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
//get the name for your image into the string however your app works
//create a string formatted like a literal HTML URL to the image, e.g.
//file:///myiPhoneFileSystemPath//MyApplication//MyApplicationDirectories//Documents//imageName.jpg
    NSString *myHTMLImageName = @"myHTMLImage.jpg";
    NSString *imagePath = [NSString stringWithFormat:@"file:///%@//%@",documentsPath,myHTMLImageName];

//this string is an example of your email body text with HTML formatting
    NSString *emailText = [NSString stringWithFormat:@"%@%@%@",@"<html><head><title>My Inline Image Example Email</title></head><body><p>Here's some text before the inline image</p><p><img src = \"",imagePath,@"\"></p><p>Here's some text for after the inline image. You could add more inline images and text after this with the same kind of formatting.</p></body></html>"];

//create email
    MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init];
    emailDialog.mailComposeDelegate = self;
    [emailDialog setSubject:@"My Inline Image Email Document"];

    [emailDialog setMessageBody:emailText isHTML:YES];

    [self presentModalViewController:emailDialog animated:YES];
    [emailDialog release];
}