Using the code below I get an exception: "Failure sending mail"
Inner exception: "No connection could be made because the target machine actively refused it 74.125.77.109:5 87"
I'm currently on my office and behind a router. My firewall is turned off.
The same situation occurs at home when behind my router with no firewall.
When I set up an new acount in outlook with the same information as in the code below it works.
I've also tried to connect to smtp.gmail.com using class TcpClient, but can't get a connection with exception: No connection could be made because the target machine actively refused it 74.125.77.109:5 87
The funny thing is that when I'm run the exact same app att a computer connected to a 3G-router it works! This mean it has to something with my computer settings or the router at my office and home.
Does anyone know where and how I have to configure to get this to work?
Inner exception: "No connection could be made because the target machine actively refused it 74.125.77.109:5 87"
I'm currently on my office and behind a router. My firewall is turned off.
The same situation occurs at home when behind my router with no firewall.
When I set up an new acount in outlook with the same information as in the code below it works.
I've also tried to connect to smtp.gmail.com using class TcpClient, but can't get a connection with exception: No connection could be made because the target machine actively refused it 74.125.77.109:5 87
The funny thing is that when I'm run the exact same app att a computer connected to a 3G-router it works! This mean it has to something with my computer settings or the router at my office and home.
Code:
MailMessage mail = new MailMessage();
mail.To.Add("me2@hotmail.com");
mail.Subject = "subject";
mail.From = new System.Net.Mail.MailAddress("me@gmail.com");
mail.IsBodyHtml = false;
mail.Body = "Body";
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.Port = port;
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential("me@gmail.com", "myPassword");
smtp.Send(mail);
Comment