Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send HTML email with Gmail 4.2.1

Tags:

It seems that Gmail 4.2.1 may have broken HTML-formatted emails. The following code worked perfectly prior to 4.2.1. The email that was sent from Gmail had the desired embedded links, bolded and underlined words. Unfortunately, after updating to 4.2.1, the email that gets sent appears as if all the HTML formatting has been stripped out. I am hoping there may be a workaround for this that maybe someone has found?

final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); String[] toArr = new String[] { "[email protected]" }; intent.putExtra(Intent.EXTRA_EMAIL, toArr); intent.putExtra(Intent.EXTRA_SUBJECT, "This is a subject"); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("Hello, here is some <b>bold text</b> some <u>underline text</u> and <a href=\"http://www.google.com\">a link</a>.")); 

The interesting thing (or maybe not?) is that the compose preview of this email message shows all of the bolded, underlined and linked text as one would expect it to appear. But when it gets sent, the recipient gets the email with all of that stuff stripped out.

And yes, I am aware of this other question about this that was closed. I think that maybe it was closed prematurely and am hoping that the additional detail here may warrant another look.

MORE INFORMATION: Upon further research, this problem is way bigger than just sending HTML email via intents. If one creates a draft email using the GMail web app that has some formatting (bold, underline, hyperlinks, etc.), then open that draft email on your GMail Android app (v4.2.1) it will appear that all of your formatting has been kept. However, if you then send that draft email using your GMail Android app, all of your formatting will be stripped out before the email is sent.

like image 882
Scott W Avatar asked Dec 07 '12 02:12

Scott W


People also ask

How do I access HTML in Gmail?

To view your Gmail in simple HTML, open the Gmail HTML website in any web browser and log in to your Gmail account if prompted, then select I'd like to use HTML Gmail. You may have to go to the Gmail HTML website again if Gmail automatically opens the standard interface.


2 Answers

This was almost certainly a bug in GMail 4.2.1.

As of March 19, 2013, GMail 4.3 was released which appears to fix the bug.

like image 128
Scott W Avatar answered Oct 06 '22 00:10

Scott W


I'm sorry that you ran into this too Scott. I filed a bug report with Google in December but that just seems to be a black hole.

My need was to embed hyperlinks. My best work-around has been to send a text/plain or message/rfc822 email with the URL in plain text in the message. Oddly Gmail recognizes this and attempts to enclose it in < a > < /a > tags. Using this method I can get the link sent and clickable by the recipient but it looks like crap.

It's also a bit of a challenge to get the URL formatted such that Gmail recognizes the entire text of the link and properly encloses it.

like image 32
Doug Gerecht Avatar answered Oct 06 '22 00:10

Doug Gerecht