tags:

views:

63

answers:

2

Hi!
I want to use Mail Composer which should attach an image file also, how is this possible?

+1  A: 

You can test this code, it's perfectly working...

MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];

    mailController.mailComposeDelegate = self;

    [mailController setSubject:@"Hello iPhone"];

    [mailController setMessageBody:@"This is the MailSend Application...." isHTML:NO];

    UIImage *pic = [UIImage imageNamed:@"Image box with border-1.png"];
    NSData *exportData = UIImageJPEGRepresentation(pic ,1.0);
    [mailController addAttachmentData:exportData mimeType:@"image/jpeg" fileName:@"Picture.jpeg"];


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

- (void)mailComposeController:(MFMailComposeViewController*)mailController 

didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 

{

        [self becomeFirstResponder];

    [self dismissModalViewControllerAnimated:YES];

}
Ankit Vyas
+1  A: 

It is possible to attach an image the test code provided on the other answer should work but as a second source the same code located at Apress at this url Mail Pic should be able to assist you with a working example. Download the folder and open the MailPic folder for the project file.

Rugluds