Java – Send HTML in the body of the email

Send HTML in the body of the email… here is a solution to the problem.

Send HTML in the body of the email

I’m trying to send an email that contains HTML, but the HTML is literal. How do I send an HTML link? Here is my current code :

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]
{"[EMAIL PROTECTED]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Subject");
<b>emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"<html><body>Example</body></html>"); </b>
context.startActivity(Intent.createChooser(emailIntent, "Send
mail...")); 

Solution

sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<a href=\"" + link_val + "\">" + text_value+ "</a>"));

Related Problems and Solutions