I am using the following very simple code and I keep getting System.Net.Mail.SmtpException
failure sending mail. This is my code:
static void main(string[] args)
{
MailAddress from = new MailAddress("MyEmail@gmail.com", "Mr. Test");
MailAddress to = new MailAddress("AnotherEmail@gmail.com", "mr. man");
MailMessage msg = new MailMessage(from, to);
msg.Subject = "email";
msg.Body = "This is email.";
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Send(msg);
}
I have never tried programmatically sending email before so I appreciate the help.