MailMessage c# - How to make it HTML and add images etc?

前端 未结 5 2195
夕颜
夕颜 2020-12-01 21:06
string to = \"email@hotmail.co.uk\";
 string body = \"Test\";
 SmtpClient SMTPServer = new SmtpClient(\"127.0.0.1\");
 MailMessage mailObj = new MailMessage(urEmail,         


        
5条回答
  •  星月不相逢
    2020-12-01 21:28

    On the MailMessage set the property IsBodyHtml to true.

    string to = "email@hotmail.co.uk";
    string body = "Test";
    SmtpClient SMTPServer = new SmtpClient("127.0.0.1");
    MailMessage mailObj = new MailMessage(urEmail, to, subject, body);
    
    mailObj.IsBodyHtml = true; // This line
    
    SMTPServer.Send(mailObj);
    

提交回复
热议问题