01 | using System.Net.Mail; |
02 | public void send_email( string msg, string mysubject, string address) |
03 | { |
04 | MailMessage message = new MailMessage( "abc@yahoo.com.tw" , address); //MailMessage(寄信者, 收信者) |
05 | message.IsBodyHtml = true ; |
06 | message.BodyEncoding = System.Text.Encoding.UTF8; //E-mail編碼 |
07 | message.Subject = mysubject; //E-mail主旨 |
08 | message.Body = msg; //E-mail內容 |
09 | |
10 | SmtpClient smtpClient = new SmtpClient( "127.0.0.1" , 25); //設定E-mail Server和port |
11 | smtpClient.Send(message); |
12 | } |
13 |
14 | send_email( "測試內容" , "測試主旨標題" , "xyz@yahoo.com.tw" ); //呼叫send_email函式測試 |
更詳細說明請參照:http://sdrv.ms/1koYEco
沒有留言:
張貼留言