您的位置:首页 > 大数据 > 人工智能

using System.Web.Mail to send email

2007-09-02 11:11 441 查看
there are many demos for send a email with c sharp language .however,you will find that most of them will be failed because of SMTPServer.Especially,authorization is required.

 


public void SendEMail()




        ...{


            MailMessage mail = new MailMessage();


            mail.Priority = MailPriority.High;


            mail.From = "cccc@gmail.com";


            mail.To = "cccc@163.com";


            mail.Subject = "Send EMail System Demo";


            mail.Body = "Just for test.";


            mail.BodyEncoding = Encoding.UTF8;




            // authorization


            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 1);


            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendemailaddress", mail.From);


            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress", mail.From);


            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname", "cccc@163.com");


            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "cccc");


            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);


            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.163.com");




            SmtpMail.SmtpServer = "smtp.163.com";


            SmtpMail.Send(mail);


        }


        #endregion

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  email authorization c