gpt4 book ai didi

android - 如何在电子邮件中发送带有 html 表格输出的电子邮件

转载 作者:行者123 更新时间:2023-11-29 14:15:40 25 4
gpt4 key购买 nike

我正在处理 ArrayList,我想发送带有 arraylist 内容的 html 格式的电子邮件,我正在尝试在 BufferedWriter 中写入数组内容,例如 ..

mOrderList = db.getOrderList();
// getting all arrayList content
for (int i = 0; i < mOrderList.size(); i++) {
no = mOrderList.get(i).getId();
itemName = mOrderList.get(i).getOrderItemName();
unit = mOrderList.get(i).getOrderUnit();
qty = mOrderList.get(i).getOrderQTY();
rate = mOrderList.get(i).getOrderRate();
amt = mOrderList.get(i).getOrderAmount();
try {
mbufferWriter =new BufferedWriter(new FileWriter("/data/data/com.sample.category/abc.txt"));
mbufferWriter.write("<html><h4>Customer Order List</h4>" + "<body> <table>"
+ "<tr><th>Item No</th>" + "<th>Item Name</th>"
+ "<th>Unit</th>" + "<th>QTY</th>" + "<th>Item Rate</th>"
+ "<th>Amount</th></tr>");
mbufferWriter.append("<tr><td>" +no+"</td>");
mbufferWriter.append("<td>"+itemName+ "<td>");
mbufferWriter.append("<td>"+unit+ "<td>");
mbufferWriter.append("<td>"+qty+ "<td>");
mbufferWriter.append("<td>"+rate+ "<td>");
mbufferWriter.append("<td>"+amt+ "<td></tr>");
mbufferWriter.append("</body></table></html>");
mbufferWriter.close();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}//for

并尝试发送这样的电子邮件,但出现错误...

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL,
new String[] { "abc@gmail.com" });
i.putExtra(Intent.EXTRA_SUBJECT, "sample email sending");

i.putExtra(Intent.EXTRA_TEXT,Html.toHtml((Spanned) mbufferWriter));

try {
startActivity(Intent.createChooser(i, "Send mail..."));
// startActivity(i);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(EmailActivity.this,
"There are no email clients installed.",
Toast.LENGTH_SHORT).show();
}

谁能帮我解决这个问题..提前致谢..

最佳答案

Html.toHtml不支持 <table> .它仅支持 <b><u><i> 等基本标签...

关于android - 如何在电子邮件中发送带有 html 表格输出的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15918954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com