System.Web.Mail.SmtpMail Send SSL 465 port exception

1.9k views Asked by At

I use System.Web.Mail class to send mail due to System.Net.Mail not supported implicit SSL. My code is the next:

 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);

When I run SmtpMail.Send method I got the following exception:

System.Web.HttpException (0x80004005): The transport failed to connect
to the server. ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException: The transport failed to
connect to the server.

--- End of inner exception stack trace --- at
System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters) at
System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParams) at
System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj,
String methodName, Object[] args) at
System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj,
String methodName, Object[] args) at
System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message) at
System.Web.Mail.SmtpMail.Send(MailMessage message)

I try to find a solution for this, for example maybe this is a permission issue on firewall/gateway, but the right person already checked it, so it's fine.

0

There are 0 answers