Tutorial :iPhone - how can I embed images in email from my app?


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?



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);  


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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »