Alex Rivera | Logout

How to add a UIImage in MailComposer Sheet of MFMailComposeViewController

Asked 2009-10-06T18:44:46.100
53

I want to insert a UIImages inside the compose sheet of an 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.

Edit
Report

1 Answer

-1

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

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).

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).

- (void)createEmailWithInlineImages {
//get app Documents directory
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsPath = [pa
answered 2010-03-11T10:37:54.237

Your Answer