1

I have an email feature in my app. So i have added the \t\t so that there is a tabbed space between the first date and the value. This appears fine in the device too. But when the email is received, there is just one space between the strings and it is not tabbed. Hence the data does not appear in columns but jagged. Is there any method by which i can achieve the same look in the email received? How can i format text in EmailComposeTask?

string test = "";
strheading = "heading";
for (int j = 0; j < pCycMan.GetWeightCount(); j++)
{
    test= test+ pCycMan.GetWeightDateByIndex(j).ToString("dd-MMM-yyyy") + "\t\t" + pCycMan.GetWeightByIndex(j) + "\n";
}
var emailComposeTask = new EmailComposeTask
{
    To = "emailid",
    Subject = "tezt",
};
emailComposeTask.Body = strheading + test;
emailComposeTask.Show();

EDIT :- I also tried the following code inside the for loop which did not work.

string temp2 =pCycMan.GetWeightByIndex(j);
StringBuilder sb = new StringBuilder(pCycMan.GetWeightDateByIndex(j).ToString("dd-MMM-yyyy"));
sb.Append("\t");
sb.Append(temp2);
sb.AppendLine();
weight = weight + sb.ToString();
4

1 回答 1

2

例如,如果您在浏览器中观看电子邮件,那么所有标准空格都可以被破坏,因为它会被浏览器忽略。因此,您需要查看原始电子邮件数据,以确认它确实缺少您发送的标签。例如,在 Mozilla Thunderbird 中,您按下Ctrl+U以查看原始消息数据。在 Gmail 中,您单击回复按钮附近的向下箭头,然后选择Show original选项。

如果您想直观地格式化文本,最好使用 HTML 表格来格式化类似表格的数据。指定“Content-Type: text/html”,然后用数据创建 html 文档(注意,应该正确指定编码)。

如果您想要或必须使用text/plain内容类型,那么使用空格来格式化表格数据会更安全,例如:

+------------+-------+-------+-------+-------+
| Date       | Load  | Quota | Warn  | Err   |
+------------+-------+-------+-------+-------+
| 2012-08-23 |   0.37|     5%|      0|      0|
| 2012-08-22 |   0.45|     5%|      0|      0|
| 2012-08-21 |   0.30|     5%|      0|      0|
+------------+-------+-------+-------+-------+

但是,电子邮件客户端仍然必须使用等宽字体才能正确读取此表格,否则表格边框和数据将“流动”。

于 2012-09-04T07:58:18.777 回答