I'm developing an application which sends emails to the smtp.gmail.com server.
When I'm connected to an ordinary network, it works perfectly. But, the network of my company occurs the following error:
System.Net.WebException: Unable to connect to remote server --- > System.Net.Sockets.SocketException: A connection attempt failed because the connected component did not respond \ r \ nright after a period of time or the established connection failed \ r \ nbecause the connected host did not respond 64.233.186.108: n at System.Net.Sockets.Socket.DoConnect (EndPoint endPointSnapshot, SocketAddress socketAddress) \ r \ n at System.Net.ServicePoint.ConnectSocketInternal (Boolean connectFailure, Socket s4, Socket s6, Socket & socket, IPAddress & address, ConnectSocketState state , IAsyncResult asyncResult, Exception & exception) \ r \ n --- End of internal exception stack trace --- \ r \ n at System.Net.ServicePoint.GetConnection (PooledStream PooledStream, Object owner, Boolean async, IPAddress & address, Socket & abortSocket, Socket & abortSocket6) \ r \ n at System.Net.PooledStream.Activate (Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) \ r \ n at System.Net.PooledStream.Activate (Object owningObject, Gen eralAsyncDelegate asyncCallback) \ r \ n at System.Net.ConnectionPool.GetConnection (Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) \ r \ n at System.Net.Mail.SmtpConnection.GetConnection (ServicePoint servicePoint) \ r \ n on System. Net.Mail.SmtpTransport.GetConnection (ServicePoint servicePoint) \ r \ n at System.Net.Mail.SmtpClient.GetConnection () \ r \ n at System.Net.Mail.SmtpClient.Send (MailMessage message) "
I'm using port 587 and left EnableSsl = true
Can this be because of the corporate network proxy?
Here is the snippet of the code responsible for the settings:
MailMessage mensagemEmail = new MailMessage();
mensagemEmail.From = new MailAddress(Remetente, "Novo Registro");
mensagemEmail.Subject = Assunto;
mensagemEmail.Body = enviaMensagem;
mensagemEmail.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
NetworkCredential cred = new NetworkCredential(StringsProjeto.remetente, StringsProjeto.pass);
client.Credentials = cred;
client.Send(mensagemEmail);