Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add an image in email body

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

like image 565
Niranj Patel Avatar asked Mar 09 '11 10:03

Niranj Patel


People also ask

How do I put a picture in the body of a Gmail email?

What to Know. Gmail on the web: Compose a message, and then drag and drop the picture from your computer to the desired position in the email. Or, position the cursor where you want the image to appear, select Insert Photo > Inline, then choose your photo and select Insert.

How do you put an image in the body of an email in HTML?

To attach an image, you need to have the encoding scheme of the image you want to attach. This is the base64 string of the picture. You can get this by right-clicking on the image you want to attach, copy the image address, and paste it into the HTML text.


2 Answers

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.

like image 75
Niranj Patel Avatar answered Oct 07 '22 22:10

Niranj Patel


Here is a related question.

It seems that you can use:

intent.putExtra(Intent.EXTRA_STREAM, uri); 

where uri is a file path URI.

like image 41
Matthew Willis Avatar answered Oct 07 '22 21:10

Matthew Willis