VS.NET发送普通邮件原码
public static void SendMail(string toEmail,string bodyEmail,string subjectEmail)
{
try
{
MailMessage mm = new MailMessage();
mm.From = new MailAddress("MESSYSTEM@AMATECH.CN","MES系統");
//MailAddress mafrom = new MailAddress("MESSYSTEM@AMATECH.CN", "MES系統");
//mm.From = mafrom;
mm.To.Add(toEmail);
mm.Body = bodyEmail;
mm.Subject = subjectEmail;
mm.Priority = MailPriority.High;
SmtpClient sc = new SmtpClient();
sc.Host = "172.22.236.5";
string userid = "";
string pswd = "";
string domain = "";
userid = "pega\roy_gu";
pswd = "@xiaoli123"
domain = "mail.sz.honyun.cn"
sc.Credentials = new System.Net.NetworkCredential(userid, pswd, domain);
sc.DeliveryMethod = SmtpDeliveryMethod.Network;
sc.Send(mm);
}
catch
{
MessageBox.Show("郵件未能成功能發送,\r\n請與管理員聯繫!", "MES系統", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}