0

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();
}
WarrenFaith
  • 56,949
  • 25
  • 133
  • 147
Aamirkhan
  • 7,031
  • 11
  • 48
  • 75
  • see [how-to-send-html-email](http://stackoverflow.com/questions/2007540/how-to-send-html-email) and [android-send-html-mail-using-intent](http://stackoverflow.com/questions/2544141/android-send-html-mail-using-intent) – Francesco Vadicamo Feb 03 '12 at 11:16
  • 1
    Please don't use CAPSLOCK in title... – WarrenFaith Feb 03 '12 at 11:19

2 Answers2

1

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:"));
Ramesh Solanki
  • 2,966
  • 4
  • 27
  • 43
  • Is it possible to create a table format in email body? Table tag is not supported and for div , styleshit is not sup0ported. – Dharmendra Apr 17 '12 at 04:13
0

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.

anddev
  • 3,086
  • 12
  • 37
  • 70