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 7416695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:33:01+00:00 2026-05-29T07:33:01+00:00

Possible Duplicate: how can send a file as attachment in objective c I want

  • 0

Possible Duplicate:
how can send a file as attachment in objective c

I want to add an image as an attachment in my iPhone application.Now I am attaching the image like this:

NSMutableString * body = [[NSMutableString alloc] initWithString:@"<html><body><img src=\"http://url here\"/>"];
[body appendString:@"</body></html>"];
[mailer setMessageBody:body isHTML:YES];

But instead of url I want to include an image which is in my resource folder.

How can I do the same?

  • 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-29T07:33:02+00:00Added an answer on May 29, 2026 at 7:33 am

    From apple documentation about MFMailComposeViewController; basically you must init the UIImage with your image, extract the image data (e.g.: if it is a PNG use UIImagePNGRepresentation()) and provide the right mime type e.g. image/png. Then use the specified function below (the file name is a name of a file you want to give to the attachment; e.g. “image.png”)

    addAttachmentData:mimeType:fileName:
    Adds the specified data as an attachment to the message.
    
    - (void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename
    
    Parameters
    attachment
    The data to attach. Typically, this is the contents of a file that you want to include. This parameter must not be nil.
    mimeType
    The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be nil.
    filename
    The preferred filename to associate with the data. This is the default name applied to the file when it is transferred to its destination. Any path separator (/) characters in the filename are converted to underscore (_) characters prior to transmission. This parameter must not be nil.
    Discussion
    This method attaches the specified data after the message body but before the user’s signature. You may attach multiple files (using different file names) but must do so prior to displaying the mail composition interface. Do not call this method after presenting the interface to the user.
    
    

    Example:

    
    UIImage *myImage = [UIImage imageNamed:@"my_bundled_image"];
    NSData *myImageData = UIImagePNGRepresentation(myImage);
    [mailComposerViewController addAttachmentData:myImageData mimeType:@"image/png" fileName:"my_image.png"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I convert my java program to an .exe file ?
Possible Duplicate: How can I pre-set arguments in JavaScript function call? (Partial Function Application)
Possible Duplicate: Elevating process privilege programatically? I'd like to build a console application in
Possible Duplicate: How to programmatically send SMS on the iPhone? i am new to
Possible Duplicate: How to send an NSDictionary (or plist file) as NSData using GameKit
Possible Duplicate: SMS from web application Sample code to send Mail via php //
Possible Duplicate: SMS from web application Sample code to send Mail via php //
Possible Duplicate: Is it possible to reverse-engineer my iPhone application? I am building an
Possible Duplicate: Sending email in .NET through Gmail I want to send an email
Possible Duplicate: Can't get Twitter OAuth callback authentication to work in Cocoa application I

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.