如何在system.net.mail中发送富文本消息

时间:2021-08-28 18:14:24

how to send rich text message in system.net.mail need code for send a mail as html

如何在system.net.mail中发送富文本消息需要代码来发送邮件为html

3 个解决方案

#1


1  

//create the mail message
 MailMessage mail = new MailMessage();

 //set the addresses
 mail.From = new MailAddress("me@mycompany.com");
 mail.To.Add("you@yourcompany.com");

 //set the content
 mail.Subject = "This is an email";
 mail.Body = "<b>This is bold</b> <font color=#336699>This is blue</font>";
 mail.IsBodyHtml = true;

 //send the message
 SmtpClient smtp = new SmtpClient("127.0.0.1");
 smtp.Send(mail);

#2


3  

System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.Body = "<html>...</html>";
mm.IsBodyHtml = true;

#3


1  

You should be aware, that not every person/mailclient can present a message formatted in HTML. If you rely on layout to make your message clear this can be a problem.

您应该知道,并非每个人/ mailclient都可以呈现以HTML格式化的消息。如果您依靠布局来清除消息,则可能会出现问题。

#1


1  

//create the mail message
 MailMessage mail = new MailMessage();

 //set the addresses
 mail.From = new MailAddress("me@mycompany.com");
 mail.To.Add("you@yourcompany.com");

 //set the content
 mail.Subject = "This is an email";
 mail.Body = "<b>This is bold</b> <font color=#336699>This is blue</font>";
 mail.IsBodyHtml = true;

 //send the message
 SmtpClient smtp = new SmtpClient("127.0.0.1");
 smtp.Send(mail);

#2


3  

System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.Body = "<html>...</html>";
mm.IsBodyHtml = true;

#3


1  

You should be aware, that not every person/mailclient can present a message formatted in HTML. If you rely on layout to make your message clear this can be a problem.

您应该知道,并非每个人/ mailclient都可以呈现以HTML格式化的消息。如果您依靠布局来清除消息,则可能会出现问题。