1

I am trying to send an HTML table through email, but what i only get is a string with the HTML code. I read about email newsletter a little but i didn't figure out how to make it work in my android test application.

I have a regular table that insert into String string.

String string = "<table border='1' align='center'><tr style='color:blue'><th>Day</th><th>Date</th><th>Start Time</th><th>End Time</th><th>Total Time</th></tr><tr><td align='center'>Sunday</td><td align='center'>19/07/2011</td><td align='center'>13:00</td><td align='center'>19:00</td><td align='center'>06:00</td></tr></table>";    
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, getSenderList());
intent.putExtra(Intent.EXTRA_SUBJECT, mContext.getText(R.string.app_name));
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(string));
mContext.startActivity(intent);

Someone can please point me how to do that?

Thanks

Moshik L
  • 410
  • 1
  • 5
  • 14
  • If you are sending emails through that Intent params like above, it will not work in emulator. That intent code works only on real device. – Ravi Bhatt Jul 31 '11 at 08:12
  • If you are sending emails through that Intent params like above, it will not work in emulator. That intent code works only on real device. – Ravi Bhatt Jul 31 '11 at 08:12
  • Thanks, but i already tried it in a real device and it also didn't work. It sends the mail but what i get on the other side is HTML code text. – Moshik L Jul 31 '11 at 08:24

1 Answers1

1

Check out the following question: Send HTML mail using Android intent.

If you want to use the default mailer, change your code to the following:

    String body = "<table border='1' align='center'><tr style='color:blue'><th>Day</th><th>Date</th><th>Start Time</th><th>End Time</th><th>Total Time</th></tr><tr><td align='center'>Sunday</td><td align='center'>19/07/2011</td><td align='center'>13:00</td><td align='center'>19:00</td><td align='center'>06:00</td></tr></table>";

    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:" + getSenderList()));
    intent.setType("text/html");
    intent.putExtra(Intent.EXTRA_SUBJECT, mContext.getText(R.string.app_name));
    intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
    mContext.startActivity(intent);
Community
  • 1
  • 1
Lawrence Barsanti
  • 31,929
  • 10
  • 46
  • 68