0

I need some portion of my email body to be in bold. I tried many solutions but didn't get the result. Can anyone point out what went wrong in my code?

String body = "<html><body><b>" + getName() + "</b></body></html>";
String myURL =  "http://www.google.com"

Intent intent = new Intent(Intent.ACTION_SEND).setType("text/plain")
            .putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.email_subject, getName()))
            .putExtra(Intent.EXTRA_EMAIL, new String[] {context.getString(R.string.email_address)})
            .putExtra(Intent.EXTRA_TEXT, new StringBuilder(Html.fromHtml(body))
            .append("\n")
            .append(myURL);

return Intent.createChooser(intent, null);

Thanks in advance.

Anju
  • 9,379
  • 14
  • 55
  • 94
  • have you tried setType("text/html") – Devrim Mar 04 '14 at 08:21
  • @aegean I saw that we can't use "text/html" if you are using EXTRA_TEXT (http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND) – Anju Mar 04 '14 at 08:23
  • Is it working if you try putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body)); (without appending \n and myUrl)? – Devrim Mar 04 '14 at 08:27
  • @aegean yes…this is working..but if I append its not…what may be the reason for that? – Anju Mar 04 '14 at 08:30
  • possible duplicate of [How to send HTML email](http://stackoverflow.com/questions/2007540/how-to-send-html-email) – Howli May 11 '14 at 23:31
  • Here you have solution: http://stackoverflow.com/questions/2007540/how-to-send-html-email – piotrpo Mar 04 '14 at 08:22

2 Answers2

1

Use it like this.

String tempString= getName.toString();
SpannableString spanString = new SpannableString(tempString);
spanString.setSpan(new StyleSpan(Typeface.BOLD), 0, spanString.length(), 0);
InnocentKiller
  • 5,234
  • 7
  • 36
  • 84
0

you can use

Html.fromHtml("<b>"+YOUR STRING+Html.fromHtml("</b>"));
Menna-Allah Sami
  • 580
  • 4
  • 19