1. 程式人生 > >c# 坑人的發郵件組件

c# 坑人的發郵件組件

郵件 端口 format rom .com smtp system add ssl加密

System.Net.Mail 在服務器25端口被封禁的情況下,無法使用其它諸如SSL 465端口發送。用過時的System.Web.Mail卻可以。是微軟更新速度太快呢,還是標準不一致呢。

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
    mail.To = "[email protected]";
    mail.From = "[email protected]";
    mail.Subject = "test";
    mail.BodyFormat 
= System.Web.Mail.MailFormat.Html; mail.Body = "test222"; mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //身份驗證 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", mail.From); //郵箱登錄賬號,這裏跟前面的發送賬號一樣就行 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword
", "123456"); //這個密碼要註意:如果是一般賬號,要用授權碼;企業賬號用登錄密碼 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);//端口 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");//SSL加密 System.Web.Mail.SmtpMail.SmtpServer = "smtp.163.com"; //企業賬號用smtp.exmail.qq.com
System.Web.Mail.SmtpMail.Send(mail);

c# 坑人的發郵件組件