从联系表格格式报文 [英] Format message from contact form
问题描述
我有发送电子邮件的联系表格。
I have contact form which is sending email.
但是,如果我在文本区域,然后点击提交,我在这封邮件中一行显示后键入长消息。
But if I type a long message in the text area and after clicking submit, in my email this message displaying in single line.
例如,如果我输入,在消息文本区:
e.g if i type that in Message text area:
My super Mesasge
My Mesasge Mesasge
From Test.
在我的邮箱这将是这样的:
In my email box it will be like:
My super Mesasge My Mesasge Mesasge From Test.
为什么格式化(/ R / N),迷路,我怎么能保持该消息的格式?
Why the formatting("/r/n") getting lost and how could i keep the formatting of that message?
更新:
我用AntiXSS.4.0.1
例如:model.Message:sdfsdf \\ r \\ nsdfsdf \\ r \\ nsdfsdfsdafsdfa
UPDATE: I used AntiXSS.4.0.1 e.g: model.Message: "sdfsdf\r\nsdfsdf\r\nsdfsdfsdafsdfa"
我这样做:
model.Message = model.Message.Replace("\r\n", "<br />");
//result: model.Message="sdfsdf<br />sdfsdf<br />sdfsdfsdafsdfa"
比
model.Message = Sanitizer.GetSafeHtmlFragment(model.Message);
//result: model.Message="sdfsdf<br>\r\nsdfsdf<br>\r\nsdfsdfsdafsdfa"
那么,为什么Sanitizer.GetSafeHtmlFragment添加\\ r \\ n回来? BR /&GT;并且还&LT改变
到&LT; BR&GT;
推荐答案
这将取决于你如何发送电子邮件。如果您使用HTML( message.IsBodyHtml
),那么你需要更换 \\ r \\ n
与&LT; BR /方式&gt;当填充
的 message.Body
This will depend on how you are sending the email. If you use HTML (message.IsBodyHtml
) then you need to replace \r\n
with <br/>
when populating the message.Body
.
这篇关于从联系表格格式报文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!