Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

android - Send HTML email with Gmail 4.2.1

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...