Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send html content with image through android default email client?

Tags:

android

email

Image describing the requirement for android 2.2+ Devices

How can we get inline images in default email client for android through Hypertext Markup Language (HTML) ?

like image 915
saikiran Avatar asked Feb 28 '13 13:02

saikiran


People also ask

How to embed image in email body?

Position your cursor where you want the image in your message. Select Insert > Pictures. Browse your computer or online file locations for the picture you want to insert. Select the picture, then select Insert.

What are embedded emails?

Embedding an image into an email message is the act of adding the image into the coding of the email template for it to appear amongst the text once the subscriber opens it, instead of appearing as an email attachment.


2 Answers

String body ="<html><body><table>...</table></body></html>";

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body).toString());                    
startActivity(Intent.createChooser(emailIntent, "Email:"));

Unfortunately, the <table> ,'img' tag isn't supported. Supported tags are actually more dependent on the email client you use to send the email - some of them are more finicky/restrictive than others. Most of them use the super-basic formatting tags like <b>, <i>, <h1>, and so on, though.

like image 39
Arpit Garg Avatar answered Sep 28 '22 17:09

Arpit Garg


You can not. As default Email application's doesn't support <img /> tag.

Because, ImageSpan doesn't implementing Parcelable.

Hence its failed with Intent's PUT_EXTRA.

Its works only for basic tags, like, <b>, <i> ..etc

Look at Sending html email in android using <table>, etc. - is there really no relatively built-in Intent way? and How to show an image in the email body?

like image 121
user370305 Avatar answered Sep 28 '22 16:09

user370305