<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A Dash of Web and Mobile Development &#187; email</title>
	<atom:link href="http://blog.iangclifton.com/tag/email/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.iangclifton.com</link>
	<description>Discussing trends and technologies in web and mobile development</description>
	<lastBuildDate>Fri, 03 Feb 2012 05:15:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Sending HTML Email With Android Intent</title>
		<link>http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/</link>
		<comments>http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/#comments</comments>
		<pubDate>Tue, 18 May 2010 02:55:15 +0000</pubDate>
		<dc:creator>Ian G. Clifton</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://blog.iangclifton.com/?p=216</guid>
		<description><![CDATA[It&#8217;s very easy to send email via an Android intent. Here&#8217;s an example where we already have the subject and body prepared but want to let the user decide on the recipient: (It&#8217;s important to note that this should be &#8230; <a href="http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s very easy to send email via an Android intent.  Here&#8217;s an example where we already have the subject and body prepared but want to let the user decide on the recipient:</p>
<pre class="brush: java; title: ; notranslate">
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType(&quot;text/plain&quot;);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
startActivity(Intent.createChooser(emailIntent, &quot;Email:&quot;));
</pre>
<p>(It&#8217;s important to note that this should be attempted on a real device.)<span id="more-216"></span></p>
<p>I ran into some trouble with sending HTML in an email because it was being interpreted as plain text both in the user&#8217;s email client and in the recipient&#8217;s.  Simply changing the MIME type didn&#8217;t help, but I eventually came across the solution:</p>
<pre class="brush: java; title: ; notranslate">
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType(&quot;text/html&quot;);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(emailIntent, &quot;Email:&quot;));
</pre>
<p>Note that both the MIME type is changed and the EXTRA_TEXT is now set as <code>Html.fromHtml(body)</code> instead of just being passed a string with HTML in it.  As long as the mail app that is selected is able to properly handle the Intent (e.g., the Gmail app can, the default mail app cannot), then HTML email can be sent.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
	</channel>
</rss>

