在.Net Framework 1.1中,对这一需求有了考虑,在MailMessage组件中增加了Fields集合易增加ESMTP邮件服务器中的寄送者身份验证的问题。不过,这一方法仅适用于.Net Framework 1.1,不适用于.Net Framework 1.0版本。带有寄送者身份验证的邮件发送程序如下:
<%@ Import Namespace="System.Web.Mail" %><script runat="server">MailMessage mail=new MailMessage(); mail.From="service@brookes.com"; mail.To="brookes@brookes.com"; mail.BodyFormat=MailFormat.Text; mail.Body="a test smtp mail."; mail.Subject="hello." mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "brookes"); //set your username here mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "walkor"); //set your password here SmtpMail.SmtpServer="lsg.moon.net"; SmtpMail.Send(mail);</script>
不过这种方法对sina的邮件不管用,希望大家注意
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18