1

I want to send a HTML e-mail when an user decides to share my app. I'm using HTML in order to have a customised and appellative message.

First approach, I tried to create a String with my HTML (inline style) using Html.fromHtml but when I received the e-mail it was pure txt, no customization.

Second approach, send a HTML file attached. The problem with this approach is that the HTML is not showed until the user opens the attach.

What's the best solution, is it possible? Thanks!

GuilhE
  • 11,591
  • 16
  • 75
  • 116

2 Answers2

2

You can achieve your task using this method Html.fromHtml(String);

Html.fromHtml("<font color='#ff123456'>text</font>")
Ajay S
  • 48,003
  • 27
  • 91
  • 111
  • Hum I was using that method and it wasn't working. Now that I've tested your small example it worked. Let me parse my HTML and try to find what could be causing the problem ;) – GuilhE Mar 22 '13 at 16:13
  • If I try something like: Html.fromHtml("123456") it doesn't work... – GuilhE Mar 22 '13 at 16:24
  • 123456 it should be after 123. – Totoo Mar 22 '13 at 16:44
  • @GuilhE I shared my knowledge to send HTML to email. I guess it should be work rest of this please try on it own. – Ajay S Mar 22 '13 at 16:47
0

You can pass Spanned text in your extra. To ensure that the intent resolves only to activities that handle email (e.g. Gmail and Email apps), you can use ACTION_SENDTO with a Uri beginning with the mailto scheme. This will also work if you don't know the recipient beforehand:

final Intent shareIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "The Subject");
shareIntent.putExtra(
Intent.EXTRA_TEXT,
Html.fromHtml(new StringBuilder()
    .append("<p><b>Some Content</b></p>")
    .append("<small><p>More content</p></small>")
    .toString())
);
Hasham
  • 455
  • 4
  • 11