標籤:style blog color os cti for
using System;using System.Collections.Generic;using System.Linq;using System.Net.Mail;using System.Text;using System.Threading.Tasks;namespace QQEmail{ class Program { static void Main(string[] args) { for (int i = 0; i < 50; i++) { MailMessage mymail = new MailMessage(); mymail.From = new System.Net.Mail.MailAddress("郵箱@qq.com"); mymail.To.Add("[email protected]"); mymail.Subject = "C#自動發送郵件測試 From HaoLiu TO [email protected]"; mymail.Body = "不好意思,我在測試程式,剛才把QQ號寫錯了,Sorry!"; mymail.IsBodyHtml = true; SmtpClient smtpclient = new SmtpClient(); smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpclient.Host = "smtp.qq.com"; smtpclient.Credentials = new System.Net.NetworkCredential("郵箱@qq.com", "密碼"); try { smtpclient.Send(mymail); Console.WriteLine("發送成功"); } catch (Exception ex) { Console.WriteLine("發送郵件失敗.請檢查是否為qq郵箱,並且沒有被防護軟體攔截"); } } } }}