Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending HTML formatted email in Android

I have successfully created an Android app that calculates prices and then is able to transfer that data in a preformatted fashion to an email program of the users choice. Depending upon the data the user creates in the app, a string containing the HTML is read into an intent. The code I have for this is:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(emailText));
QuoteDroid.this.startActivity(emailIntent);

This is all fine and the email is mostly formated correct when I choose the Gmail app, and generally sends mostly correct. The issue I have with this is that I must send it from a non-gmail account for business purposes. When I choose the generic email app on the phone it does not process the HTML properly and when I send the email it is formated in plain text.

I've read through countless articles and forum posts, but to no avail. How do I process the string, containing the HTML, in such a way that the email -after being sent with the built in email app- is viewed properly formated by the receiver?

like image 248
Duncan Hill Avatar asked Nov 15 '22 04:11

Duncan Hill


1 Answers

It's up to the individual mail app to properly handle the String that it receives as the EXTRA_TEXT. A well-behaved mail app will see the mimetype and handle the EXTRA_TEXT appropriately, but not all mail apps do.

like image 94
Ian G. Clifton Avatar answered Nov 17 '22 05:11

Ian G. Clifton