Here is a technique I use for sending an email using GMail.
Notice: You might need to change your email settings under Forwarding and POP/IMAP inside your GMail settings (to Enable POP).
Here is a test program for using the class library (shown in the snippet box):
using System;
namespace TestSendGmail
{
using SendGmail;
class Program
{
static void Main(string[] args)
{
string strError = "";
if(!CSendGmail.SendMail(
// credential from a secure source
GetCred.CGetCred.GetCred("GMAIL"),
"Test Subject", // subject
"someone@somewhere.com", // To:
"test message", // Body
"", // Attachment
ref strError // returned error message,if any
))
{
Console.WriteLine("Could not send mail: " + strError);
return;
}
Console.WriteLine("Finished");
}
}
}