简体   繁体   中英

How to send HTML Mail in Android

IO want to send email in html format in android. I am able to send mail via gmail client but I am not able to get the styles of html of when I use any other client. I have used below code

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/html");

i.putExtra(Intent.EXTRA_SUBJECT, "TestMail");
i.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<p><b>Some Content</b></p>"));

try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(EmailHtmlActivity.this, "There are no email clients installed.",Toast.LENGTH_SHORT).show();
}

try this

final 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));
startActivity(Intent.createChooser(emailIntent, "Email:"));

try this I am not sure but it may be help you..

startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND).setType("message/rfc822")
.putExtra(Intent.EXTRA_SUBJECT, subject)
.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(new String().concat("YOUR MESSAGE")), 
 "Send your email in:"));

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