Why does MFMailComposer with <img> not display the image in the mail?
I mailed some images using MFMailComposer. I convert an image to Base64 and use the <img> to add images to the HTML body (I do not add it as an attachment).
[htmlString appendFormat: @"<img src='data:image/png;base64,%@' width=300 height=200 />", imageAsBase64]; Images are displayed correctly in MFMailComposer, but there are no images displayed in the actual mail that is sent from MFMailComposer.
What to do to make it work?
I had the same problem for a couple of weeks, and I found out that Gmail does not support inline images. You can see images by email in another email provider, such as your domainβs email, but not in Gmail.
Try sending another email and you will see the images. You need to add images as an attachment, then you can see the images and the lower part of your email body will be displayed on it.
I hope for this help.
You must add images as an attachment. The received email, which you see using HTML, does not display correctly with the missing image URL.
here is an example: the caveat is that if you want to include things like PDF, you must include the image, otherwise mfmailcomposer will fail ... this is in Apple's error.
I found a solution ... Apple radar bug about this was emitted. MFMailcomposer has an error in which you need to send an image along with your additional attachments in order to get strange elements like PDF to work ... try this and replace the pdf with your card:
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; NSString *emailSubject = [NSString localizedStringWithFormat:@"MedicalProfile"]; [controller setSubject:emailSubject]; NSString *fileName = [NSString stringWithFormat:@"%@.pdf", profileName]; NSString *saveDirectory = NSTemporaryDirectory(); NSString *saveFileName = fileName; NSString *documentPath = [saveDirectory stringByAppendingPathComponent:saveFileName]; *** YOU MUST INCLUDE AN IMAGE OR THE PDF ATTATCHMENT WILL FAIL!!!*** // Attach a PDF file to the email NSData *pdfData = [NSData dataWithContentsOfFile:documentPath]; [controller addAttachmentData:pdfData mimeType:@"application/pdf" fileName:fileName]; // Attach an image to the email NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"miniDoc" ofType:@"png"]; NSData *imageData = [NSData dataWithContentsOfFile:imagePath]; [controller addAttachmentData:imageData mimeType:@"image/png" fileName:@"doctor"]; [controller setMessageBody:[NSString stringWithFormat:@"%@ Medical Profile attatched!", profileName] isHTML:NO]; [self presentModalViewController:controller animated:YES]; controller.mailComposeDelegate = self; [controller release];