2010-06-05 65 views
0
using System; 
using System.Net; 
using System.Net.Mail; 

class MainClass 
{ 
    public static void Main(string[] args) 
    { 
     SmtpClient client = new SmtpClient("192.168.1.12", 25); 


     using (MailMessage msg = new MailMessage()) 
     { 
      msg.From = new MailAddress("[email protected]"); 
      msg.Subject = "***Dexter DB***"; 

      msg.Body = "***DB backup done***"; // I want to change this so i can do this in html file - how do i pick up this file and send a html form? 

      msg.To.Add(new MailAddress("[email protected]")); 
      client.Send(msg); 
     } 
    } 
} 

回答

2
msg.IsBodyHtml = true; 
+0

那么我如何添加电话文件? – neilos 2010-06-05 16:19:26

+0

like that:msg.Attachments.Add(new Attachment(@“C:\ windows \ win.ini”));你想添加一个html附件或者有一个html格式的邮件吗? – Tony 2010-06-05 16:22:18

+0

html格式的邮件消息 – neilos 2010-06-05 16:23:30

0

关闭我的头顶

msg.Body = File.ReadAllText("c:\\temp\\somefile.html"); 
msg.IsBodyHtml = true; 

但是,如果这个页面中有一个HTML表单,它可能无法在某些邮件客户端工作,因为有些邮件客户端之前,它剥去邮件此功能显示给收件人。

相关问题