Possible Duplicate:
Sending email in .NET through Gmail
I tried sending e-mail with Gmail SMTP and System.Net.Mail as follows:
Dim objSMTPClient As New System.Net.Mail.SmtpClient("smtp.gmail.com", 465) 'also tried 587
objSMTPClient.EnableSsl = True
objSMTPClient.UseDefaultCredentials = False
objSMTPClient.Credentials = New System.Net.NetworkCredential("email@domain.com", "password")
objSMTPClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
objSMTPClient.Send(objMailMessage)
However, when I try port 465, I get an exception "The operation has timed out." And when I try port 587, I get the exception "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at "
Any idea why?
Thanks in advance.
UPDATE: The problem seems to have solved itself as of tonight. I don't know what changed. Perhaps something on the Google side. In any case, the code is working; I'd love to know what was wrong so I can make sure it does not happen again, and also to help the community, but I can't get it into the not-working state so I can try things and test it.
ALSO: I beg to differ with the moderator who marked my question as a duplicate of another thread -- that thread simply asked generically how to send mail via Gmail. I read that thread, and was doing everything it said to do, but it didn't work for me, so I posted error messages and asked what was wrong.
I would like to point readers to this other thread which is actually closer to being my duplicate, and which I couldn't find earlier, and which has numerous possible suggestions which could possibly have helped, except that the problem is gone now so I can't test it. Thanks all!