Search code examples
vb.netemailgmail

Sending emails with Gmail and C#/VB.Net no longer works


When I try to send an email with Gmail using VB.Net or C# I keep getting the following message: Failure sending email - An attempt was made to access a socket in a way forbidden by its access permissions - Unable to access remote server. I have tried using several Gmail accounts including VB.Net code that worked in the past, like the following:

Message = New MailMessage(Sender, Recipient, Subject, MessageBody)

SMTPServer = New SmtpClient("smtp.gmail.com", 587)'Port 465 fails as well
SMTPServer.EnableSsl = True

SMTPServer.Credentials = New NetworkCredential("[email protected]", "password")
SMTPServer.Send(Message)

(I am aware that the web.config can be used for a lot of the above).

Obviously Gmail must have changed some setting or something similar?


Solution

  • It was McAfee Anti-Virus preventing the sending of emails. Thanks for all the help, and sorry for wasting everyones time.