views:

1079

answers:

1

Is it possible to embed a reference to an image in an HTML email sent via MFMailComposeViewController on iPhone OS 3.0?

(void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename

doesn't seem to provide any way of either setting or reading the Content-ID header for an attachment, but is there some way to make this work?

I have seen apps that do this, but they're probably using SKPSMTPMessage...

+4  A: 

Hey David,

I believe you can use an HTML tag in the email's body to achieve what you're looking for. It's not common, but the img's src attribute can actually be set to base-64 encoded image data. For instance, you can say "<img src='data:image/gif;base64,R0lGODlhUAAPAKIA......'>" and embed the image data inline.

Here's an article with more information: http://www.sweeting.org/mark/blog/2005/07/12/base64-encoded-images-embedded-in-html

I know for a fact that this works in Mobile Safari, but I've never used it in Mail. It seems like it would work - I'm sure they use WebKit to render the HTML email messages as well.

Good luck!

Ben Gotow
OK, that's worth trying, since it's only for small images... but it might be easier just to use the more flexible SKPSMTPMessage and get support for OS 2.2 also...
David Maymudes
Good call. I think you definitely don't want to start embedding megabytes worth of base-64 data!
Ben Gotow
somehow it still feels vaguely illicit to use a "private" email sending API rather than the officially approved one, but I suppose in this case it's really okay.
David Maymudes