Android 在电子邮件意图中用粗体字不起作用
我想在字符串中加粗一些单词,然后将该字符串传递给想要发送它的电子邮件。很明显,这是行不通的。我正在使用Html.fromHtml。请帮忙!下面是相关的类代码Android 在电子邮件意图中用粗体字不起作用,android,email,fonts,bold,Android,Email,Fonts,Bold,我想在字符串中加粗一些单词,然后将该字符串传递给想要发送它的电子邮件。很明显,这是行不通的。我正在使用Html.fromHtml。请帮忙!下面是相关的类代码 final Spanned messageEmail = Html.fromHtml("Dear " + name + ",<br><br>" + " <b>your payslip n
final Spanned messageEmail = Html.fromHtml("Dear " + name + ",<br><br>" + " <b>your payslip number is</b> " + payslipno +" and your net salary for the period "
+ startofpayslip + " till " +
endofpayslip + " is "+ netsalary + " and it is issused on " + issuedate + ". According to the agreed overtime rate of " + agreedovertimerate +
" from " + startofovertimeperiod + " till " + endofovertimeperiod + ", your net salary is calculated by adding your basic salary of " +
basicsalary + " to your available allowance of " + typeofallowance + " of " + allowanceamt + " on " + allowancedate + ", " +
"and any other extra payment of" + extrapayment + " and deducting from " + typeofdeduction
+ " of " + deductionamt + " on " + deductiondate + ". Your availabe allowance for this month is "
+ availableallowance + ".") ;
Log.i("Send email", "");
String[] TO = {email};
String[] CC = {""};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/html");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Payslip for period " + startofpayslip + " till " + endofpayslip);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.toHtml(messageEmail));
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(EmployeePaySlip.this,
"There is no email client installed.", Toast.LENGTH_SHORT).show();
}
The result of the text message will be like <p> dir = "ltr> Dear Mary, </p> <p dir="ltr">      <b> your payslip number is </br> and so on and so for...
final-span-messageEmail=Html.fromHtml(“亲爱的”+name+,
“+”您的工资条编号为“+payslipno+”,您在该期间的净工资
+开始工资单+“至”+
endofpayslip+“是“+netsalary+”,在“+issuedate+”上发布。按照约定的加班费率“+AgreedVertimerate+
从“+startofovertimeperiod+”到“+EndofVertimePeriod+”,您的净工资是通过将您的基本工资相加计算的+
“基本日历+”到您的可用津贴“+typeofallowance+”或“+allowanceamt+”在“+allowancedate+”上的“+typeofallowance+”的“+allowanceamt+”+
以及任何其他额外支付“+额外支付+”并从“+扣除类型”中扣除的款项
+您本月的可用津贴为
+可用流量+”);
Log.i(“发送电子邮件”);
字符串[]TO={email};
字符串[]CC={”“};
意向emailIntent=新意向(Intent.ACTION\u SEND);
setData(Uri.parse(“mailto:”);
emailIntent.setType(“text/html”);
emailIntent.putExtra(Intent.EXTRA_电子邮件,收件人);
emailIntent.putExtra(Intent.EXTRA_CC,CC);
emailIntent.putExtra(Intent.EXTRA_主题,“期间工资单”+开始工资单+“直至”+结束工资单);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.toHtml(messageEmail));
试一试{
startActivity(Intent.createChooser(emailIntent,“发送邮件…”);
Log.i(“已完成发送电子邮件…”,”);
}捕获(android.content.ActivityNotFoundException ex){
Toast.makeText(EmployeePaySlip.this,
“没有安装电子邮件客户端。”,Toast.LENGTH_SHORT)。show();
}
短信的结果会像亲爱的玛丽一样,&160;&160;&160;&160;&160;&160;你的工资条号码是等等。。。
我可以知道我在这里遗漏了什么吗?我尝试删除了Html。从Html中,消息将是正常的,但字体不会是粗体的。非常感谢任何帮助!!我想你必须传递你的字符串(没有跨距)与您的电子邮件正文一样。我不能,它将有错误。类型不匹配:无法从span转换为String可能我不清楚:String eMailMEssage=“亲爱的”+name+,
“+…+可用的lowance+”。“是的,我理解,但有一个错误类型不匹配:无法从跨距转换为字符串。所以我被迫使用了跨距。好吧,也许现在我明白你的说法了。如果我把它作为字符串,我将不得不删除Html.fromHtml,结果将是正常的,但字体仍然不会是粗体。