I am using inbuilt composer of iPhone to send an email in my application. I want to add images to body of my email. Please remember I want to place images in the body and not want to attach the images to the email. I know how to attach them.
Its like I want to place multiple images in the body with some details for them in front of the respective image.
Is there any way to do that.
Like using html, the following code show me a question mark instead of an image.
NSData *imageData = [dbPersistenceObj getImageForEmail:[[imageIdArray objectAtIndex:i] intValue]];
NSString *encodedImage = [imageData description];
emailBody = [emailBody stringByAppendingFormat:@"<img src=\"cid:Img-1\"/>", imageData];
[picker addAttachmentData:imageData mimeType:@"image/png" fileName:@"Img-1"];
Edited after some experimentation
My original answer is not in fact a solution to the question. It appears that with
MFMailComposeViewControlleryou cannot reference attached images in an HTML email body using thecid:syntax.If you attach the image after setting an HTML body the iPhone will internally use
cid:to display the image, but only in the fashion in which it is normally represented in the composer view – so it’s not that flexible.Finally, it is possible to use the
data:image/png;base64,embedded image source URL scheme but this does not seem to be widely supported by email clients – notably it does not fail gracefully in GMail.Original answer:
Note: I haven’t tried this.
Assuming that you are using MFMailComposeViewController in iPhone SDK 3.0+: You could try creating an HTML format email body and reference the attached image from within that HTML document.
HTML
Objective-C