Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In WindowsService C#, I'm trying to send email through Windowsservice but it is giving an error saying that "unable to connect to the remote server" and email sending failed. I tried with the different account types that will provide when we add the project installer for the windows service such as local service, local system, network and user but issue didnt resolved, and i also truned off windows fire wall settings,group policy but still issue remains the same. please help me out. The Gmail port number and client everything is correct and if i run the same piece of code in console project it works perfectly fine with no errors and also if i run the same code in the server using windows service also it works fine but the problem is with my laptop machine,I am not able to send emails using windows service in my laptop machine , I am the administrator of my machine, I'm not finding any solutions for this problem please please help me out.


try
{
var client = new SmtpClient(smtp.gmail.com,587)
{
EnableSsl = true,
Credentials = new NetworkCredential("mamise@gmail.com","passwd")
};
client.Send("rprise@gmail.com","girish@gmail.com","Test","Test");
}
Posted
Comments
May be the Anti virus is blocking the port 587.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900