Unable to connect to remote server while sending email in asp.net

Posted by Amritha444 under ASP.NET on 10/30/2012 | Points: 10 | Views : 5548 | Status : [Member] | Replies : 1
Hi all

The above error arising while using email sending code my code is
string fromAddress = "mymail";
string fromPassword = "mypassword";

try
{
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, MailSubject, Body);
I googled many times but didnt get proper solution.Port 587 is enbled and firewall blocking also not there.




Responses

Posted by: Amritha444 on: 10/30/2012 [Member] Starter | Points: 25

Up
0
Down
hi all
I got solution as
if you are using any antivirus software check it's log to see whether it is because of the antivirus. I faced same problem when McAffee was blocking my mails (there is a security policy - Prevent mass mailing worms from sending mails). Edit this policy and add your application to the exception list. In my case this sorted the problem. Please check if it works for you.

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response