Use Table tag in Android Email

2019-01-19 18:41发布

问题:

I want my app to construct some HTML and pass it over to an email so my user can send it to whomever they want. I found code on the web that shows how to pass the html via an Intent, but it appears that Html.fromHtml(String source) doesn't understand table tags. Is there anyway I can format an email with table tags? I want to send it through the user's preferred client instead of sending it myself with javamail.

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
activity.startActivity(Intent.createChooser(emailIntent, "Email:"));

Any suggestions?

回答1:

Unfortunately, the <table> tag isn't supported. Supported tags are actually more dependent on the email client you use to send the email - some of them are more finicky/restrictive than others. Most of them use the super-basic formatting tags like <b>, <i>, <h1>, and so on, though. The more layout-oriented tags are a lot more spotty, and some (like <table>) aren't supported at all.