I am having a weird issue. Last night I did a piece of code to send email via Gmail smtp server and it worked ok from my home. However, I found this does not work in office this morning.
I followed all the settings information provided by Google(see the link below):
I also 'telnet' the port 465 on smtp.gmail.com in command window and it successfully connected. But if I tried to send email from .net code, it always end up with exception 'System.Net.Mail.SmtpExcep
tion: The operation has timed out. at System.Net.Mail.SmtpClient
Message message) '.
my code is as below:
any idea, guys? not sure if my office computer has any setting problem or our company network has any rule to stop this working
private void SendEmail()
var message = new MailMessage("email@example.com", "firstname.lastname@example.org", "mail to myself", "empty body");
var smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("email@example.com", "xxxxxxx");
smtp.Port = 465;
catch (Exception ex)