简体   繁体   中英

how to send E-mail html content with images in mail body using android

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM