mail.Body = "your appointment has been scheduled on :" + txtappointment.Text + " " + txtmessage.Text;
答案 0 :(得分:0)
试试这个
mail.Body ="your appointment has been scheduled on :"+ <br> + txtappointment.Text +" "+ txtmessage.Text;
答案 1 :(得分:0)
对于新行,您应该使用\n
。或者看看这篇较老的帖子:
Adding a newline into a string in C#
答案 2 :(得分:0)
你可以尝试这个+Environment.NewLine+
mail.Body ="your appointment has been scheduled on :"+ <br> + txtappointment.Text +System.Environment.NewLine+ txtmessage.Text;
答案 3 :(得分:0)
这是解决问题的示例,在我的代码段中的注释中尝试一次,您的答案。
ng-bind-html
答案 4 :(得分:0)
根据你的意见,你需要这样的东西(你应该使用string.Format
方法来轻松管理字符串:
mail.Body = string.format("your appointment has been scheduled on: {0}<br/>{1}", txtappointment.Text, txtmessage.Text);
您可以看到文本编辑器文本的占位符,第一个用于约会,第二个用于消息。要使html起作用,您必须为此设置IsBodyHtml
标志:
mail.IsBodyHtml = true;
如果您的电子邮件客户端不支持html,或者您不希望它是html,请使用Environment.NewLine
常量,如@AsifuzzamanRedoy建议的那样:
mail.Body = string.format("your appointment has been scheduled on: {0}{2}{1}", txtappointment.Text, txtmessage.Text, Environment.NewLine);