Reputation: 11901
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!
Upvotes: 1
Views: 1182
Reputation: 455
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())
);
Upvotes: 0
Reputation: 48622
You can achieve your task using this method Html.fromHtml(String);
Html.fromHtml("<font color='#ff123456'>text</font>")
Upvotes: 2