How to create a multi line body in C# System.Net.Mail.MailMessage

前端 未结 14 726
忘了有多久
忘了有多久 2020-12-03 02:45

If create the body property as

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

message.Body =\"First Line \\n second line\";
         


        
14条回答
  •  余生分开走
    2020-12-03 03:05

    I usually like a StringBuilder when I'm working with MailMessage. Adding new lines is easy (via the AppendLine method), and you can simply set the Message's Body equal to StringBuilder.ToString() (... for the instance of StringBuilder).

    StringBuilder result = new StringBuilder("my content here...");
    result.AppendLine(); // break line
    

提交回复
热议问题