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

左心房为你撑大大i 提交于 2019-11-26 17:15:32

问题


I have to format the text as table in the email body of email client. But i read somewhere android doesn't
support < table> tag. Is any other alternative is there for doing this? I tried a lot but still i am not finding any good solution. Please can anyone help me.

code

String body = "< table border="+"1"+">< tr>< td>row 1, cell 1< /td>"+ "< td>row 1, cell 2"+ "< /tr>"+ "< tr>"+ "< td>row 2, cell 1< /td>"+ "< td>row 2, cell 2< /td>"+ "< /tr>"+ "< /table>";

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

Actual Output is this

But I Expected output is similar to following:


回答1:


Try this:

How to send HTML email

Ok as the above isn't working try this:

http://www.edumobile.org/android/android-programming-tutorials/how-to-send-an-email/

The code from your example does work fine for anything without table. I thought it could be forced, but I've hit a wall here.

See: Sending html email in android using <table>, etc. - is there really no relatively built-in Intent way?

Perhaps this can work around it: Display HTML Table in webview

Or perhaps you can force something like this through in your activity (adjust to suit your purpose):

WebView webview = new WebView(this); setContentView(webview); String yourHtml = "<html><body><table>...</table></body></html>"; webview.loadData(yourHtml , "text/html", "utf-8"); 


来源:https://stackoverflow.com/questions/12154790/android-how-to-format-the-text-as-table-in-email-body-of-email-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!