我正在研究 ArrayList,我想发送带有 arraylist 内容的 html 格式的电子邮件类型,我正在尝试在 BufferedWriter Like 中编写数组内容。
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();
}
谁能帮我解决这个问题..提前谢谢..