Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-11-2009, 08:37 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2008
Posts: 38
Default MFMailComposeViewController: image attachment

Hi,

I'm trying to send an email with an image attached, using MFMailComposeViewController.

Code:
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
Xavier is offline   Reply With Quote
Old 09-11-2009, 08:41 AM   #2 (permalink)
Daddy Cool
 
MarkC's Avatar
 
Join Date: Mar 2009
Location: Yorkshire, England
Age: 100
Posts: 1,462
Default

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!
MarkC is online now   Reply With Quote
Old 09-11-2009, 09:14 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2008
Posts: 38
Default

If I send a jpeg file it's working, I don't know what's the problem with my png...
Xavier is offline   Reply With Quote
Old 09-19-2009, 10:51 AM   #4 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 44
Default Not sure if this helps...

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.

Code:
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.
shabzcohelp is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 967
23 members and 944 guests
ADY, biskwit, fanarin, frank_huang, hearther, joom888, M@realobjects, MarkC, markn, mattjgalloway, mavericki, Meoz, morgen, OstinGames2011, pippo_1, Runassser, sebasx, sjr, stalkon, Stut72, Sunny46, tymex
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,491
Threads: 89,095
Posts: 380,135
Top Poster: BrianSlick (7,091)
Welcome to our newest member, Runassser
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:29 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0