private void SendMailByGmail(List<string> MailList,string Subject,string Body) { MailMessage msg = new MailMessage(); //收件者,以逗號分隔不同收件者 ex "test@gmail.com,test2@gmail.com" msg.To.Add(string.Join(",", MailList.ToArray())); msg.From = new MailAddress("test2@gmail.com", "測試郵件", System.Text.Encoding.UTF8); //郵件標題 msg.Subject = Subject; //郵件標題編碼 msg.SubjectEncoding = System.Text.Encoding.UTF8; //郵件內容 msg.Body = Body; msg.IsBodyHtml = true; msg.BodyEncoding = System.Text.Encoding.UTF8;//郵件內容編碼 msg.Priority = MailPriority.Normal;//郵件優先級 //建立 SmtpClient 物件 並設定 Gmail的smtp主機及Port #region 其它 Host /* * outlook.com smtp.live.com port:25 * yahoo smtp.mail.yahoo.com.tw port:465 */ #endregion SmtpClient MySmtp = new SmtpClient("smtp.gmail.com", 587); //設定你的帳號密碼 MySmtp.Credentials = new System.Net.NetworkCredential("Gmail帳號", "Gmail密碼"); //Gmial 的 smtp 使用 SSL MySmtp.EnableSsl = true; MySmtp.Send(msg); }
Referenece
--
http://blog.longwin.com.tw/2010/09/google-gmail-set-value-2010/
http://windows.microsoft.com/zh-tw/windows/outlook/send-receive-from-app
http://help.yahoo.com/kb/index?page=content&y=PROD_MAIL_ML&locale=zh_TW&id=SLN4724
沒有留言:
張貼留言