smtp (gmail) fails in classic asp, but works in web service

NeateAnceptex

New Member
I'm using .Net 4 c#, Windows Server 2008 R2, IIS 7 with the following code in my web service that I'm using to test sending an email. It works. I then use the same code in my classic asp app that calls .net c# via COM+ and it fails with "System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it xx.xxx.xxx.xxx:587"I have researched this for days and can't find anything that will help. Any help would be greatly appreciated. Thank you.\[code\] public static class Mail { public static void SendEmail(string subject, string body) { var fromAddress = new MailAddress("[email protected]", "From Name"); var toAddress = new MailAddress("[email protected]", "To Name"); const string fromPassword = "password"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential(fromAddress.Address, fromPassword), Timeout = 20000 }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); } } }\[/code\]
 
Top