0

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

 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):传输无法连接
到服务器。---> System.Reflection.TargetInvocationException:
调用的目标已抛出异常。--->
System.Runtime.InteropServices.COMException:传输无法
连接到服务器。

--- 内部异常堆栈跟踪结束 --- 在
System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32culture
, String[] namedParameters) 在
System.RuntimeType System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod ( Object obj
, String方法名,对象 [] 参数)在 System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(对象 obj, 字符串方法名,对象 [] 参数)在






System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage 消息)在
System.Web.Mail.SmtpMail.Send(MailMessage 消息)

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

4

0 回答 0