代碼如下:
private bool SendMail(Form2.History hsSendInfo, string warning = null)
{
try
{
string HostName = System.Net.Dns.GetHostName();
string AddressIP = string.Empty;
string SystemTime = System.DateTime.Now.ToString();
string Address = GetAddress();
MailMessage mm = new MailMessage();
mm.From = new MailAddress(hsSendInfo.Account);
mm.To.Add(hsSendInfo.Exexplain);
mm.Subject = "登錄信息提醒";
mm.Body = "XX";
mm.BodyEncoding = System.Text.Encoding.UTF8;
mm.IsBodyHtml = false;
SmtpClient sc = new SmtpClient();
NetworkCredential nc = new NetworkCredential();
nc.UserName = hsSendInfo.Account;
nc.Password = hsSendInfo.Password;
sc.UseDefaultCredentials = true;
sc.DeliveryMethod = SmtpDeliveryMethod.Network;
sc.Credentials = nc;
sc.Host = "smtp.qq.com";
sc.EnableSsl = true;
sc.Send(mm);
}
catch
{
return false;
}
return true;
}
不明請追問