I am using MFMailComposeViewController class to send out formatted HTML email from my iPhone app. I need to include an image in the email and I added am IMG tag to my emailb
Here is the code which was working for me,
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
// We must always check whether the current device is configured for sending emails
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
MFMailComposeViewController *composeVC = [[MFMailComposeViewController alloc] init];
composeVC.mailComposeDelegate = self;
[composeVC setSubject:@"test"];
NSString *messageBody = @"";
[composeVC setMessageBody:messageBody isHTML:NO];
UIImage *artworkImage = viewImage;
NSData *artworkJPEGRepresentation = nil;
if (artworkImage)
{
artworkJPEGRepresentation = UIImageJPEGRepresentation(artworkImage, 0.7);
}
if (artworkJPEGRepresentation)
{
[composeVC addAttachmentData:artworkJPEGRepresentation mimeType:@"image/jpeg" fileName:@"Quote.jpg"];
}
NSString *emailBody = @"Find out more App at Test";//add code
const char *urtfstring = [emailBody UTF8String];
NSData *HtmlData = [NSData dataWithBytes:urtfstring length:strlen(urtfstring)];
[composeVC addAttachmentData:HtmlData mimeType:@"text/html" fileName:@""];
//Add code
[self presentModalViewController:composeVC animated:YES];
[composeVC release];
[self dismissModalViewControllerAnimated:YES];
UIGraphicsEndImageContext();