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

前端 未结 5 2185
夕颜
夕颜 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:10

    There are two ways of doing this:

    1. Embed the images inside your mail. (see this question)

    2. Link to the images through your src attribute of the image tag inside your HTML mail. This needs you to host the image files somewhere on a webserver which the recipients can access.

    In both cases you will need to send the mail with a html body.

    mailObj.IsBodyHtml = true;
    

提交回复
热议问题