Using SWIFT I need to send an image in the email body with some other text content on it. just tried in following way and I can send the email...
In iPhone sent items it have properly sent, but in gmail it doesn't render properly. The image tag is printed as plain text...
if MFMailComposeViewController.canSendMail()
{
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setToRecipients(["myemail@gmail.com"])
mailComposerVC.setSubject("Sample Title")
var body: String = "<html><body><h1>My Image as below</h1> <br/>"
if let imageData = UIImagePNGRepresentation(myImageView.image) // Get the image from ImageView and convert to NSData
{
var base64String: String = imageData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.allZeros)
body = body + "<div><img src='data:image/png;base64,\(base64String)' height='100' width='150'/></div>"
}
body = body + "</body></html>"
mailComposerVC.setMessageBody(body, isHTML: true)
self.presentViewController(mailComposerVC, animated: true, completion: nil)
}
Can't really get the point where I am going wrong in here...