I am writing an android app and at some point I need to send an email to a user specified address. To do this I am opening an email app and filling in the subject and body allowing the user to fill in the recipient. The email being sent should be html that I pull from a pre specified webpage. Pulling the html from the web is simple, but won't display properly when emailed. The code I am using to open the email app is:
intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.shareSubject));
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(intent, "Email:"));
This should allow the user to select their email client and send an html email if the selected client supports it. I have been testing with the gmail app which has been reported to support it, but when the email is received it is in plain text.
If it helps, the code I am essentially using to get the code is:
String input;
String body = "";
try
{
URL url = new URL("<url>");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
while((input = in.readLine()) != null)
body = body + input;
}
catch(MalformedURLException e)
{
}
catch(IOException e)
{
}
I'm not sure why this is failing, everything I have looked at says that the gmail app supports sending html emails and that this is the code to do it. Any help would be appreciated.