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");
}