Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 667057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:53:12+00:00 2026-05-13T23:53:12+00:00

I want to insert a UIImage s inside the compose sheet of an MFMailComposerViewController

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:53:12+00:00Added an answer on May 13, 2026 at 11:53 pm

    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…

    - (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!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert something into a STL list in C++, but I only
I want to insert say 50,000 records into sql server database 2000 at a
I want to insert a new row into an Access database. I'm looking at
I want to insert multiple invisible watermarks into my JPEG pictures through C# code.
I want to insert a pair< string, vector<float> > into a map, first it
I have a vector that I want to insert into a set . This
As the subject says I want to insert an image into the 2nd column
I want my JTextPane to insert spaces whenever I press Tab. Currently it inserts
I want to use javascript to insert some elements into the current page. Such
I want to do something like insert into my table (select * from anothertable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.