Reputation: 304
how to send E-mail html content with images in mail body using android
My code :
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"to");
emailIntent.putExtra(android.content.Intent.EXTRA_CC,"cc");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(body));
this.startActivity(Intent.createChooser(emailIntent, "Choose your email program"));
But mail body not display some html contains and images.
Please Help me.
Advance Thanks.
Upvotes: 0
Views: 2010
Reputation: 13415
Try with this :
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(new StringBuilder()
.append(body).toString()));
Instead of :
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(body));
EDIT :
Here is my test and it is working well.
String body = "<html><body><h1>this is h1</h1><b>wel come to html formet</b></body></html>";
final Intent shareIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "The Subject");
shareIntent.putExtra(
Intent.EXTRA_TEXT,
Html.fromHtml(new StringBuilder()
.append(body).toString())
);
startActivity(shareIntent);
Thanks.
Upvotes: 1