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

  • Home
  • SEARCH
  • 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 937217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:26:28+00:00 2026-05-15T21:26:28+00:00

I am using MFMailComposeViewController class to send out formatted HTML email from my iPhone

  • 0

I am using MFMailComposeViewController class to send out formatted HTML email from my iPhone app. I need to include an image in the email and I added am IMG tag to my emailbody

- (IBAction)shareWithOther
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"My Message Subject"];

    NSString *emailBody = @"<h3>Some and follow by an image</h3><img src=\"SG10002_1.jpg\"/>and then more text.";
    [picker setMessageBody:emailBody isHTML:YES];

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

the image file, “SG10002_1.jpg” was added to my Resource Folder, but the image didn’t show up in the message body (only displayed as [?]).
Can someone please tell me what I am doing wrong like if the path of the image is wrong or is there a better way to do this?

Thanks a lot.

  • 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-15T21:26:29+00:00Added an answer on May 15, 2026 at 9:26 pm

    I strongly believe (from your question) that your image SG10002_1.jpg is located in main bundle.
    If it is so, then below code should work for you. It’s a complete hack from this question.

    - (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];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 512k
  • Answers 512k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's really wrapping not hyphenation. And one can overcome this… May 16, 2026 at 5:32 pm
  • Editorial Team
    Editorial Team added an answer Try this: // get the total number of images inserted… May 16, 2026 at 5:32 pm
  • Editorial Team
    Editorial Team added an answer Apparently there is a way to have a Web Browser… May 16, 2026 at 5:32 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm using the MFMailComposeViewController to send an email from within an iPhone v3.0 application.
I am sending an email from my iPhone app using MFMailComposeViewController. This works fine
I'm using MFMailComposeViewController for in-app email in my app, but I'm not able to
I'd like to send a text outline via email using MFMailComposeViewController. I'm currently doing
I am using the MFMailComposeViewController in 3.0 to send an email with attachment etc.
I am trying to send mail using MFMailComposeViewController. Everything works, except that mails do
I am creating my second iPhone app, and I've included a feedback form using
Using the below XML, I need to figure out which person worked more hours
I'm trying to open the email view controller ( MFMailComposeViewController ), and everything I
Does MFMailComposeViewController come only in English!? I am toying around with the idea of

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.