I am working on app, where i wanna sent an image in email body. I am using following code for the same, mail sent but image not shown in image body, Can any one help me for the same.
//Create a string with HTML formatting for the email body
NSMutableString *emailBody = [[NSMutableString alloc] initWithString:@"<html><body>"];
//Add some text to it however you want
[emailBody appendString:baseStr];
//Pick an image to insert
//This example would come from the main bundle, but your source can be elsewhere
UIImage *emailImage = [UIImage imageNamed:@"face.png"];
//Convert the image into data
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)];
//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/png;base64,%@'></b></p>",base64String]];
//You could repeat here with more text or images, otherwise
//close the HTML formatting
[emailBody appendString:@"</body></html>"];
NSLog(@"%@",emailBody);
//Create the mail composer window
MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init];
emailDialog.mailComposeDelegate = self;
[emailDialog setSubject:@"A Message from Emoji App"];
NSArray *toRecipients = [NSArray arrayWithObjects:@"mandeepz.rimt@gmail.com", nil];
[emailDialog setToRecipients:toRecipients];
[emailDialog setMessageBody:emailBody isHTML:YES];
[self presentViewController:emailDialog animated:YES completion:nil];