Display local image in iPhone HTML mail

后端 未结 5 2264
谎友^
谎友^ 2020-12-17 05:07

In my app, I am composing an HMTL email message with the 3.0+ MFMailComposeViewController. To do this, I created an HTML file, with some placeholders. In my cod

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 05:57

    I don't know if the HTML format is a must have for you, but actually embedding an image in an email can be achieved without using HTML, just with image as attachment.

    Just have a look at the way it is achieved here :

    http://iphone-dev-tips.alterplay.com/2009/11/attaching-image-of-uiview-to-email.html

    the crucial part is this :

    // ATTACHING A SCREENSHOT
    NSData *myData = UIImagePNGRepresentation(screenshot);
    [controller addAttachmentData:myData mimeType:@"image/png" fileName:@"route"];
    

    You get the PNG representation of your UIImage (as NSData) and you attach it yo your email.

提交回复
热议问题