tags:

views:

798

answers:

3

Hi

Is it possible to embed images an email being sent from my app? Can we have an tag with source as an image in our app?

Thanks.

+1  A: 

Yes. Using 3.0's mail APIs you can.

I'll not put the code here because it is under the NDA. It is well documented in the SDK though. You need to get the image data into an NSData which is not as obviously documented:

NSData* imageData = UIImagePNGRepresentation(myUIImage);
Roger Nolan
Thanks. But I am looking at using the 2.2.1. The method I use now works great between Apple's mail apps but doesn't work with all clients. https://devforums.apple.com/message/32106#32106
lostInTransit
A: 

The short answer is that you can't.

The long answer - I just came across this which includes the TTMessageController class. You'd need to add a delegate to actually do the sending though - i.e. implement SMTP and talk to a known SMTP server. That's not too complicated in itself, but adds some complications regarding error handling, particularly because there's no background processing.

For example, if your app exits before you've sent the email then you'll need to remember your state and send it next time you start up. The Apple mail application would just send it in the background.

Airsource Ltd
A: 

You can send via MFMailComposeViewController. Look the sample of attaching an image to email.

slatvick