System.Web.Mail.SmtpMail发送SSL 465端口异常

时间:2014-12-17 15:15:23

标签: c# system.web.mail

我使用System.Web.Mail类发送邮件,因为System.Net.Mail不支持隐式SSL。 我的代码是下一个:

 System.Web.Mail.MailMessage email = new System.Web.Mail.MailMessage();

 string SEND_USING = "http://schemas.microsoft.com/cdo/configuration/sendusing";
 string SMTP_SERVER = "http://schemas.microsoft.com/cdo/configuration/smtpserver";
 string SMTP_SERVER_PORT ="http://schemas.microsoft.com/cdo/configuration/smtpserverport";
 string SMTP_USE_SSL = "http://schemas.microsoft.com/cdo/configuration/smtpusessl";
 string SMTP_AUTHENTICATE = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate";
 string SEND_USERNAME = "http://schemas.microsoft.com/cdo/configuration/sendusername";
 string SEND_PASSWORD = "http://schemas.microsoft.com/cdo/configuration/sendpassword";

 email.Fields[SEND_USING] = 2;
 email.Fields[SMTP_SERVER] = Conf_SmtpServer;    //is valid
 email.Fields[SMTP_SERVER_PORT] = Conf_Port;     //465
 email.Fields[SMTP_USE_SSL] = Conf_SmtpSsl;      //true
 email.Fields[SMTP_AUTHENTICATE] = 1;
 email.Fields[SEND_USERNAME] = Conf_EmailAddress;
 email.Fields[SEND_PASSWORD] = Conf_PassWord;


 email.From = Conf_FeladoEmailNev + "<" + Conf_DisplayName + ">";
 email.To = System.Convert.ToString(dr["EMAIL"]);

 email.Subject = System.Convert.ToString(dr["TARGY"]);
 email.BodyFormat = System.Web.Mail.MailFormat.Text;
 email.Body = System.Convert.ToString(dr["TEXT"]);

 System.Web.Mail.SmtpMail.Send(email);

当我运行SmtpMail.Send方法时,我得到以下异常:

  

System.Web.HttpException(0x80004005):传输无法连接
  到服务器。 ---&GT; System.Reflection.TargetInvocationException:
  调用的目标抛出了异常。 ---&GT;
  System.Runtime.InteropServices.COMException:传输失败   连接到服务器。

     

---内部异常堆栈跟踪结束---在
  System.RuntimeType.InvokeDispMethod(String name,BindingFlags
  invokeAttr,Object target,Object [] args,Boolean [] byrefModifiers,
  int32文化,String [] namedParameters)在   System.RuntimeType.InvokeMember(String name,BindingFlags
  bindingFlags,Binder binder,Object target,Object [] providedArgs,
  ParameterModifier []修饰符,CultureInfo文化,String []
  namedParams)在   System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj,
  字符串methodName,Object [] args)在
  System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj,
  字符串methodName,Object [] args)在
  System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage消息)在
  System.Web.Mail.SmtpMail.Send(MailMessage消息)

我试图为此找到解决方案,例如,这可能是防火墙/网关上的权限问题,但是合适的人已经检查过它,所以没关系。

0 个答案:

没有答案