0

Hi I am trying to send mail from my android application but I am not getting proper mail in my inbox my code is here please help me.

Spanned mailBody2 = Html.fromHtml("<body><table width=\"200\" border=\"1\"><tr bgcolor=\"#3399FF\"><td>hi</td><td>gaurav</td><td>patel</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></body>");

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String[] recipients = new String[] { "jansodariya@gmail.com" };
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,recipients);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Summ");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,mailBody2);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Merlyn Morgan-Graham
  • 58,163
  • 16
  • 128
  • 183
Jignesh Ansodariya
  • 12,583
  • 24
  • 81
  • 113

2 Answers2

0

Change

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,mailBody2);

to

String mailtext="<body><table width=\"200\" border=\"1\"><tr bgcolor=\"#3399FF\"><td>hi</td><td>gaurav</td><td>patel</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></body>";  

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(mailtext));

This should work. refer this link. Hope it helps.

Adil Soomro
  • 37,609
  • 9
  • 103
  • 153
Piyush Patel
  • 1,765
  • 1
  • 16
  • 29
0

You cannot do this. You only can send text trough an email. You must use php to send formatted mails. Please read here also Send HTML mail using Android intent

Community
  • 1
  • 1
Dany's
  • 943
  • 1
  • 7
  • 17