MailMessage sent string as body without newline in outlook

前端 未结 10 872
挽巷
挽巷 2020-12-11 15:44

HI, I am trying to send a simple notification using system.net.mail.mailmessage. I just pass the string as the message body. But problem is even though multi-line message be

10条回答
  •  旧时难觅i
    2020-12-11 16:28

    //the email body should be HTML //replaces the new line characters \n\r with the break HTML

    mailMsg.IsBodyHtml = true;
    mailMsg.Body = this.Body;
    mailMsg.BodyEncoding = System.Text.Encoding.ASCII;
    mailMsg.Body = mailMsg.Body.Replace(Environment.NewLine, "
    ");

提交回复
热议问题