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
|