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

时间:2008-09-26 07:14:21

标签: .net

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

3 个答案:

答案 0 :(得分:3)

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

答案 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 :(得分:1)

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