7

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) ?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
saikiran
  • 101
  • 1
  • 2

2 Answers2

4

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?

Community
  • 1
  • 1
user370305
  • 108,599
  • 23
  • 164
  • 151
1

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.

Arpit Garg
  • 8,476
  • 6
  • 34
  • 59