C#-发送带有换行符的HTML电子邮件 [英] C# - Send HTML email with line breaks
问题描述
我正在尝试使用System.Net.Mail.MailMessage类从C#应用发送电子邮件。对于电子邮件的正文,我想包括换行符以创建单独的文本块。在向用户显示包含HTML的电子邮件时,如何使Outlook等电子邮件客户端尊重换行符?我应该在电子邮件正文中插入哪些字符,以便将换行符视为换行符?
I'm attempting to send emails from my C# app using the System.Net.Mail.MailMessage class. For the body of the email, I want to include line breaks to create separate blocks of text. How can I get an email client, like Outlook, to respect the line breaks when display the email has HTML to users? What character(s) do I insert in the body of the email text so that the line breaks are treated as line breaks?
注意:我的电子邮件正文是纯文本文本,而不是HTML。
Note: The body of my email is pure text, not HTML.
推荐答案
您可以只使用 Environment.NewLine 属性。这将插入为当前环境定义的换行字符串。
You can just use Environment.NewLine property. That will insert a newline string defined for the current environment.
这篇关于C#-发送带有换行符的HTML电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!