How to add an image in email body

Niranj Patel picture Niranj Patel · Mar 9, 2011 · Viewed 22.4k times · Source

I want to add an image in email body. I don't want to attach an image to the email, but add an image in the email body.

How to do this?

I'm using this.

"<img src=\"data:image/png;base64,"+convertFileTOByteEncrypt()+"\">"

or

  "<img src=\"http://images.anandtech.com/doci/3982/HTCSurround-0134.jpg\">"

Then image is displayed like this.

image

Answer

Niranj Patel picture Niranj Patel · Sep 26, 2011

Unfortunately, it's not possible to do this with Intents.

The reason why for example bold text is displayed in the EditText and not an Image is that StyleSplan is implementing Parcelable whereas ImageSpan does not. So when the Intent.EXTRA_TEXT is retrieved in the new Activity the ImageSpan will fail to unparcel and therefor not be part of the style appended to the EditText.

Using other methods where you don't pass the data with the Intent is unfortunately not possible here as you're not in control of the receiving Activity.