0

I want to show TABULAR Data in an Android GMAIL Body from my app, pre-filled. There are many similar topics available on Stackoverflow, but no one has provided a good solution to my particular problem.

Here is what I am doing,

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("<!DOCTYPE html><html><body><table><tr><th>head 1</th><th>head 2</th><th>head 3</th></tr><tr><td>data 1</td><td>data 2</td><td>data 3</td></tr></table></body></html>"));
                mContext.startActivity(shareIntent);

Can anyone please check this, and let me know what I am doing wrong?

Sanat Pandey
  • 4,081
  • 17
  • 75
  • 132

1 Answers1

-2

Try below code :

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("<p><b>Some Content</b></p>")
    .append("<small><p>More content</p></small>")
    .toString())
);

For more Links see

android - How to format the text as table in email body of email client

How to send HTML email

Also do check if this works on Android 4.0 and up.

Community
  • 1
  • 1