Configuring Office365 smtp on ASP.NET 1.1 web applications
January 16, 2012 Leave a Comment
If you are still having that frustrating exception “The transport failed to connect to the server” while trying to use an Office365 smtp server settings with ASP.NET 1.1 websites or web applications, then here is the quick fix.
SmtpMail.SmtpServer = pod0000.outlook.com; //your smtp server
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusing”,”2″);
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”, “1″);
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusername”, myusername@email.com);
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendpassword”, mypassword);
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”, 25); //the confusing part is here
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpusessl”,”true”);
We know that Office365 uses SSL and the port should be 587 (or 465 in some cases) but unfortunately for some reason 587 port does not work in ASP.NET 1.1 when using CDONTS. So just plain luck, tried port 25 and the emails went through. This scenario only applies to ASP.NET 1.1 whereas ASP.NET 2.0 or later work fine with 587 port.