using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Mail; namespace FFTSendMail { class Program { static void Main(string[] args) { try { string baseDir = AppDomain.CurrentDomain.BaseDirectory; SmtpClient smtpClient = new SmtpClient(); MailMessage mail = new MailMessage(); Attachment attachment = new Attachment(baseDir + "StaeMJ_0128_WinList.csv"); //Smtp Server IP/Domain smtpClient.Host = "192.168.0.1"; //From Mail mail.From = new MailAddress("allen.su@test.com.tw", "allensu"); //Content mail.Body = "test 內容"; //Subject mail.Subject = "test 標題"; mail.BodyEncoding = System.Text.Encoding.UTF8; //To Mail mail.To.Add(new MailAddress("allen.su@test.com.tw", "allensu")); //Attachment file mail.Attachments.Add(attachment); smtpClient.Send(mail); Console.WriteLine("success"); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); } } }
2010年1月28日 星期四
Send Mail for .Net
Source Code :
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言