如何使用下划线或粗体文本从我的应用程序发送邮件? [英] How can I send mail from my app with underline or bold text?

查看:136
本文介绍了如何使用下划线或粗体文本从我的应用程序发送邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

String html = "<html><body><b<bold</b><u>underline</u></body></html>";
Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT,
Html.fromHtml(html));
startActivity(Intent.createChooser(intent, "Send Email"));

结果是正常的文本。有没有办法让这个文字粗体和下划线?

The result is normal text. Is there a way to make this text bold and underline?

推荐答案

你不能使用 html Intent.EXTRA_TEXT 根据本文档。您是否尝试使用 EXTRA_STREAM

You cannot use the type text/html with Intent.EXTRA_TEXT according to this documentation. Have you tried with EXTRA_STREAM?

另一方面,您在粗体标签中出现HTML sintax错误:

On the other hand, you have a HTML sintax error in the bold tag:

String html = "<html><body><b<bold</b><u>underline</u></body></html>";

应该是:

String html = "<html><body><b>bold</b><u>underline</u></body></html>";

更新:

这可能是您的默认电子邮件应用程序中的错误,如果可以,可以使用Gmail应用程序,看看会发生什么。更改代码有点再选择您的默认邮件客户端:

It may be a bug in your default email app, have a go with the Gmail app if you can and see what happens. Change the code a bit to choose again your default mail client:

try {
    startActivity(Intent.createChooser(intent, "Send mail"));
    Log.i("MAIL", "Finished sending email");
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(getApplicationContext(), 
    "There is no email client installed.", Toast.LENGTH_SHORT).show();
}

如下图所示,它适用于默认的邮件应用的Android框架。

As you can see in the picture below, it works with the default Mail app of the Android framework.

您是否尝试过将Project Build Target设为4.3?

Have you tried for example with the Project Build Target to 4.3?

这篇关于如何使用下划线或粗体文本从我的应用程序发送邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆