Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

MFMailComposeViewController: image attachment

XavierXavier Posts: 38Registered Users
edited September 2009 in iPhone SDK Development
Hi,

I'm trying to send an email with an image attached, using MFMailComposeViewController.
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
(...)

NSString *path = [[NSBundle mainBundle] pathForResource:@"Icon" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"Icon.png"];
	
NSString *emailBody = @"Test";
[picker setMessageBody:emailBody isHTML:NO];
	
[self presentModalViewController:picker animated:YES];
[picker release];

The image is correctly displayed when I send the email, but when I receive it the image cannot be displayed because it contains some errors.

WHat am I missing ?
Thanks
Post edited by Xavier on

Replies

  • MarkCMarkC Yorkshire, EnglandPosts: 1,944iPhone Dev SDK Supporter, Registered Users @ @ @ @
    edited September 2009
    I've got something very similar going on, the only difference being by isHTML is set to YES rather than your NO, and it works a treat!

    Try that and see if it works!
    neon_images_framed.jpg
  • XavierXavier Posts: 38Registered Users
    edited September 2009
    If I send a jpeg file it's working, I don't know what's the problem with my png...
  • shabzcohelpshabzcohelp Posts: 44Registered Users
    edited September 2009
    I was having the same problem as you. The Image was showing up in the email, but it was noticeably worse quality than the original image. I'm not sure if this applies to you guys, but this is what fixed it.
    NSData *myData = UIImageJPEGRepresentation(artworkImageView.image, 0.0);
    		[controller addAttachmentData:myData mimeType:@"image/png" fileName:@"Albumicon.png"];
    		}
    		[controller setSubject:@"Test"];
    		[controller setMessageBody:(NSString*)all isHTML:YES];
    		[self presentModalViewController:controller animated:YES];
    
    The above code was my original code with the bad quality image, and the 0.0 after the artworkImageview.image is what was causing it. I change the 0.0 to 1.0 and the quality was perfect.
Sign In or Register to comment.