To test a Mail application I’m working on, I decided to use GMail, but it wasn’t as easy as I’d hoped. Luckily, I found this code snippet on TechNet Forums that worked for me:
MailMessage msgMail = new MailMessage("?????@gmail.com", ??????@gmail.com, "subject", "message body");
Just replace the question marks with your GMail credentials, and it should work for you too.