Sending HTML email with GMail installed on G1

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


Sponsored Links
 Hello,

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);
intent.setType("text/html");
startActivity(newIntent);

The email I receive looks something like this:


MIME-Version: 1.0
Content-Type: multipart/alternative;
        boundary="----=_Part_494_24247511.1226466478922"

------=_Part_494_24247511.1226466478922
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
Ashbury,
San Francisco, CA, 94117<br/>View in Puluwai | <a href="
 http://www.agencylogic.com/googlebase/149Ashbury-com 
">Browser</a></li></ul></html>

------=_Part_494_24247511.1226466478922
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://
www.agencylogic.com/googlebase/149Ashbury-com"> http://www.agencylogic.com/googlebase/149Ashbury-com< ;/a>&quot;&gt;Browser&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/html&gt;</p>


------=_Part_494_24247511.1226466478922--
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.:

"text/xhtml"
"message/rfc822"
"message/rfc2822"
"text/plain"
"multipart/mixed"

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
SpannableString(getResources
().getString(R.string.link));
ss.setSpan(new
URLSpan(getResources().getString
(R.string.url)), 0, ss.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
SpannableStringBuilder ssb =
new SpannableStringBuilder
(getResources().getString(R.string.mail_text))
.append(' ')
.append(ss);
Intent i = new
Intent(Intent.ACTION_SEND)

.putExtra(Intent.EXTRA_TEXT, ssb)

.putExtra(Intent.EXTRA_SUBJECT,

getString(R.string.mail_subject))

.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_subject>
<R.string.mail_text> <R.string.link>.

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

Sergey

On Nov 11 2008, 9:11pm, thrusty <tcstellan...@gmail.com> 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
itsself?

I want something analog to:

{a href='http://www.google.com'}Google{/a}

instead of

{a href='http://www.google.com'}http://www.google.com{/a}


On Jan 2, 1:57pm, sergey <sergeyte...@gmail.com> 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. Keeping Surface View subclass working through orientation change?

Hi,
   I'd like to make an application where I draw on a surface, and that
surface stays active when the orientation changes from portrait to
landscape and back.

  I know I can declare a port and a land layout,  (res/layout-port,
res/layout-land) but it takes several seconds for the framework to
switch from one to the other, and during that time my class is
inactive (it is declared in the XML for the orientation).

  So, how can I make a subclass of SurfaceView (or some other thing
that I can draw on) that lives independently of the activity that is
started and stopped on orientation change?

Thanks
--~--~---------~--~----~------------~-------~--~----~

2. Orientation Sensor return false values. And getRotationMatrix() also doesn't work. Is my ADP1 broke?

Let me edit the log so it's more readable:

08-01 15:37:38.170: DEBUG/onSensorChanged(1653): Pitch: -67.0
08-01 15:37:38.210: DEBUG/onSensorChanged(1653): Pitch: -67.0
08-01 15:37:38.250: DEBUG/onSensorChanged(1653): Pitch: -67.0
08-01 15:37:38.290: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:38.330: DEBUG/onSensorChanged(1653): Pitch: -69.0
08-01 15:37:38.420: DEBUG/onSensorChanged(1653): Pitch: -110.0
08-01 15:37:38.460: DEBUG/onSensorChanged(1653): Pitch: -111.0
08-01 15:37:38.500: DEBUG/onSensorChanged(1653): Pitch: -111.0
08-01 15:37:38.590: DEBUG/onSensorChanged(1653): Pitch: -111.0
08-01 15:37:38.750: DEBUG/onSensorChanged(1653): Pitch: -112.0
08-01 15:37:38.790: DEBUG/onSensorChanged(1653): Pitch: -112.0
08-01 15:37:38.830: DEBUG/onSensorChanged(1653): Pitch: -112.0
08-01 15:37:38.880: DEBUG/onSensorChanged(1653): Pitch: -112.0
08-01 15:37:38.920: DEBUG/onSensorChanged(1653): Pitch: -69.0
08-01 15:37:39.000: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.040: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.120: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.200: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.240: DEBUG/onSensorChanged(1653): Pitch: -67.0
08-01 15:37:39.280: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.330: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.380: DEBUG/onSensorChanged(1653): Pitch: -69.0
08-01 15:37:39.430: DEBUG/onSensorChanged(1653): Pitch: -69.0
08-01 15:37:39.480: DEBUG/onSensorChanged(1653): Pitch: -70.0
08-01 15:37:39.520: DEBUG/onSensorChanged(1653): Pitch: -70.0
08-01 15:37:39.560: DEBUG/onSensorChanged(1653): Pitch: -70.0
08-01 15:37:39.600: DEBUG/onSensorChanged(1653): Pitch: -71.0
08-01 15:37:39.640: DEBUG/onSensorChanged(1653): Pitch: -72.0
08-01 15:37:39.680: DEBUG/onSensorChanged(1653): Pitch: -73.0
08-01 15:37:39.730: DEBUG/onSensorChanged(1653): Pitch: -107.0
08-01 15:37:39.770: DEBUG/onSensorChanged(1653): Pitch: -106.0
08-01 15:37:39.810: DEBUG/onSensorChanged(1653): Pitch: -108.0
08-01 15:37:39.850: DEBUG/onSensorChanged(1653): Pitch: -109.0
08-01 15:37:39.890: DEBUG/onSensorChanged(1653): Pitch: -109.0
08-01 15:37:39.930: DEBUG/onSensorChanged(1653): Pitch: -72.0
08-01 15:37:39.970: DEBUG/onSensorChanged(1653): Pitch: -72.0
08-01 15:37:40.010: DEBUG/onSensorChanged(1653): Pitch: -72.0
08-01 15:37:40.050: DEBUG/onSensorChanged(1653): Pitch: -75.0
08-01 15:37:40.090: DEBUG/onSensorChanged(1653): Pitch: -76.0

--~--~---------~--~----~------------~-------~--~----~

3. Force Close pop up when uncaught exception during background service

4. Full browser vs WebView view

5. Port AbsoluteLayout to any other Layout to draw at x,y position

6. Bug in Android Browser with Facebook fan pages? Can't bring any fan page up!

7. Android source linking fails on Ubuntu 9.04