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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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-16-2010, 03:55 AM   #1 (permalink)
Remya
 
Join Date: Dec 2009
Location: India
Posts: 65
rainmobile is on a distinguished road
Default How to embedd image in MKMailComposer

Hi,

UIImage *image = [UIImage imageWithData:data];
//dataConvertIntoPNG = UIImagePNGRepresentation(image);

NSMutableString *emailBody = [[NSMutableString alloc] initWithString:@"<html><body>" ];

//Add some text to it however you want

[emailBody appendString:@"<p></p>"];

//Pick an image to insert

//This example would come from the main bundle, but your source can be elsewhere

// UIImage *emailImage = [UIImage imageNamed:@"Twitter.png"];

//Convert the image into data

NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];

//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/gif;base64,%@'></b></p>",base64String]];

//You could repeat here with more text or images, otherwise

//close the HTML formatting
//NSMutableString *emailBody = [NSMutableString stringWithCapacity:100];
NSString *watchOrListen = appDelegate.lectureIsAudioOnly ? @"listen" : @"watch";
NSString *proposition = appDelegate.lectureIsAudioOnly ? @"to " : @"";
[emailBody appendFormat:@"I just %@ed %@this lecture on my mobile device and really enjoyed it. There are several ways that you can %@ %@it as well...",watchOrListen,proposition,watchOrListen,p roposition];
[emailBody appendString:@"<br/><br/> Stream it <br/>"];
[emailBody appendString:[appDelegate.contents objectForKey:@"App store URL"]];
[emailBody appendString:@"<br/><br/> Download it <br/> "];
[emailBody appendString:[appDelegate.contents objectForKey:@"iTunes URL"]];
[emailBody appendString:@"<br/><br/> br/>"];
[emailBody appendString:[appDelegate.contents objectForKey:@"Buy disc URL"]];
[emailBody appendString:@"<br/><br/> And watch hundreds of other lectures on your mobile device with this app:<br/>"];
[emailBody appendString:[appDelegate.contents objectForKey:@"Main Application App store URL"]];
[emailBody appendString:@"</body></html>"];




//Create the mail composer window

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

emailDialog.mailComposeDelegate = self;

[emailDialog setSubject:[appDelegate.contents objectForKey:@"Lecture title"]];

[emailDialog setMessageBody:emailBody isHTML:YES];


[self presentModalViewController:emailDialog animated:YES];




But the image is seen in mobile .But it image wont seen in mail. How can i solve this issue.

That is how to embed images in Mail Composer.Plz help me


Thanks In Advance
rainmobile is offline   Reply With Quote
Old 09-16-2010, 06:20 AM   #2 (permalink)
Registered Member
 
kelvinkao's Avatar
 
Join Date: Jul 2009
Location: Los Angeles
Posts: 352
kelvinkao is on a distinguished road
Send a message via AIM to kelvinkao
Default

I remember attempting this and was only able to see the images on the iPhone, but the images never showed on the receiving side. I believe it was because this base64 code is often used to embed malicious code, so email services tend to discard them on the receiving side. This is a dead end according to my research back then, though if I am wrong, someone please call me out on it.

You can send images as attachments, but they will be tagged on at the end of the email.
__________________
My dev blog:
http://www.kelvinkaodev.com
kelvinkao 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: 334
19 members and 315 guests
2ndSegment, bignoggins, cayladv57, cgokey, dermotos, djohnson, Domele, guusleijsten, Hamad, heshiming, linkmx, markuschow, Objective Zero, pungs, Rudy, Sloshmonster, teebee74, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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