Sending HTML email with GMail installed on G1

by thrusty » Wed, 12 Nov 2008 13:11:13 GMT

Sponsored Links

I'm trying to send HTML email using the GMail package installed on the
T-Mobile G1.  What I'm finding is that regardless of the content-type
I specify, the message body is always translated into both text/plain
and text/html ; however, the html is escaped (e.g. "<" becomes "&lt;")
so it does not display as html in the receiving email client.

Here's how I'm setting up the Intent:

String[] addresses = {aAddress};

Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, aSubject);
intent.putExtra(Intent.EXTRA_TEXT, aBody);

The email I receive looks something like this:

MIME-Version: 1.0
Content-Type: multipart/alternative;

Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<html><p>Here's a property you might want to look at:<ul><li>149
San Francisco, CA, 94117<br/>View in Puluwai | <a href=" 

Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<p>&lt;html&gt;&lt;p&gt;Here&#39;s a property you might want to look
at:&lt;ul&gt;&lt;li&gt;149 Ashbury, San Francisco, CA, 94117&lt;br/
&gt;View in Puluwai | &lt;a href=&quot;<a href="http://">< ;/a>&quot;&gt;Browser&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/html&gt;</p>

As you can see, the html is modified by gmail.  The "text/plain"
version is basically correct except for its mime type.

I've tried setting various other content types, e.g.:


No luck so far-- anyone have any ideas?


Sending HTML email with GMail installed on G1

by sergey » Sun, 04 Jan 2009 15:35:00 GMT

 ello Thrusty,

This can be solved by using Spans. Here is a piece of code which
demonstrates how it can be done:

SpannableString ss = new
(R.string.url)), 0, ss.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
SpannableStringBuilder ssb =
new SpannableStringBuilder
.append(' ')
Intent i = new

.putExtra(Intent.EXTRA_TEXT, ssb)



.setType("message/rfc822"); //$NON-NLS-1$

startActivity(Intent.createChooser(i, "Title:")); //$NON-NLS-1$

What this code does is is sending email composed of

<R.string.mail_text> <>.

Upon clicking on the link, the mail recipient will be navigated to a
site, which address is specified by <R.string.url>.


On Nov 11 2008, 9:11pm, thrusty <> wrote:


Sponsored Links

Sending HTML email with GMail installed on G1

by Noonien Soong » Thu, 29 Jan 2009 01:29:26 GMT

  question about URLSpan :

Is there a way to have a link with a different label than the URL

I want something analog to:

{a href=''}Google{/a}

instead of

{a href=''}{/a}

On Jan 2, 1:57pm, sergey <> wrote:

Re: Sending HTML email with GMail installed on G1

by goRGon Development » Tue, 25 Jan 2011 02:53:13 GMT

 Guys, just use* Html.fromHtml()* method like the following:
intent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(aBody));

Believe, this will help


Other Threads

1. How to restart scheduled jobs no phone restart

I am developing a ToDo reminder type of app for android.

on creation of a new reminder an alarm and {*filter*} scheduler is
created with a toast. This works on intents and broadcasts and is
pretty straight forward stuff with putextras using the reminder id
from the db.

My problem is, if some one restart the phone, i guess all the
scheduled alarm and {*filter*} tasks for the reminder will be killed.
Once the phone restart again how to recreate the scheduler tasks.

Can some one help me with this please?


2. Android 1.5 bug with earphone detection

On my Google dev phone there is a problem with the new 1.5 version in
combination with an official HTC adapter cable YC A300 and 3.5mm
earphones. Android doesn't recognize the earphones (it worked on
1.1!). Android still recognizes the HTC earphones with ExtUSB.


3. OpenGL ES portability...

4. Any plans to support Microsoft's ActiveSync protocol?

5. UI problem

6. How to connect to a wireless network

7. android emulator window hangs when closing window