如何将邮件发送HTML格式? [英] How to send mail in HTML format?
本文介绍了如何将邮件发送HTML格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的Android应用程序指定的地址发送邮件。但是,新的我可以只发送纯文本邮件。我想在不同颜色的一些文字加粗/强调也。你可以看到下面我在其中使用了HTML的形式大胆的我code /下划线的文字,但我得到的邮件与正常(纯)文本意味着没有什么,我应该为此做的效果。
谢谢你。
{尝试
GmailSender发件人=新GmailSender(sender_email_id,密码);
sender.sendMail(谢谢国家,+ Html.fromHtml(< U> Jignesh< / U>< B> Jignesh< / B>中)
。android.tech1q2@gmail.com,et_mail.getText()的toString()修剪());
}赶上(例外五){
Log.e(的SendMail,e.getMessage(),E);
}
解决方案
//发送URL链接通过aplication邮寄
//使用Html.fromHtml(mailBody)
字符串mailBody =你好,我想你会很喜欢这一点:+
&所述; A HREF =www.google.com>检索算法引擎与所述; / A>中+ //检索算法引擎+&所述峰; br />中+ < BR />名称:LT; BR />中+
< BR />配料+< BR />中+< BR />中;
意图emailIntent =新意图(android.content.Intent.ACTION_SEND);
emailIntent.setType(text / html的);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,检索算法引擎);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(mailBody));
startActivity(Intent.createChooser(emailIntent,发送邮件...));
I want to send mail from my android application to given address. But new I am able send only plain text message. I want some text bold/underlines in different colors also. you can see my code below in which I used html form to bold/underline text but I got mail with normal(plain) text means no effect of what should I do for this. Thanks.
try {
GmailSender sender = new GmailSender("sender_email_id","password");
sender.sendMail("Thank you state", ""+Html.fromHtml("<u>Jignesh</u><b>Jignesh</b>"),
"android.tech1q2@gmail.com", et_mail.getText().toString().trim());
} catch (Exception e) {
Log.e("SendMail", e.getMessage(), e);
}
解决方案
//Send an Url link to mail through aplication // using Html.fromHtml(mailBody)
String mailBody="Hello. I think you’d really enjoy this:"+
"<a href='www.google.com'> Serach Engine </a>"+//Serach Engine +"<br/>"+
"<br/> Name : <br/>"+
"<br/> Ingredients"+"<br/>"+"<br/>";
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Serach Engine");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(mailBody));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
这篇关于如何将邮件发送HTML格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文