Getting Error Transport error code was 0x80040217 while Sending Email in Asp.Net

Discovered that you can also get this error when Gmail's security settings don't allow messages to be sent from the address you intend to use. I had to enable access for less secure apps for my account in question by:

  1. Logging into the address you want to use for sending email from Excel.
  2. Visit the page https://www.google.com/settings/security/lesssecureapps
  3. Click Enable Less Secure Apps.
  4. Click Done.

It's caused by a wrong username or password for the SMTP server and usually means that the server has disabled your account for spamming i you've sent 1500 mails