2010-06-05 84 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表單,它可能無法在某些郵件客戶端工作,因爲有些郵件客戶端之前,它剝去郵件此功能顯示給收件人。

相關問題