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

前端 未结 14 703
忘了有多久
忘了有多久 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 02:50

    In case you dont need the message body in html, turn it off:

    message.IsBodyHtml = false;
    

    then use e.g:

    message.Body = "First line" + Environment.NewLine + 
                   "Second line";
    

    but if you need to have it in html for some reason, use the html-tag:

    message.Body = "First line 
    Second line";

提交回复
热议问题