I get the exception of
System.Net.Mail.SmtpException
...and when expanded it says
client not authenticated
how to fix?
string to, from, pas, mail;
to = "****";
from = "****";
mail = "Email Content";
pas = "****";
MailMessage message = new MailMessage();
message.To.Add(to);
message.From = new MailAddress(from);
message.Body = mail;
message.Subject = "Email Testing";
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.EnableSsl = true;
smtp.Port = 587;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(from, pass);
try
{
smtp.Send(message);
System.Diagnostics.Debug.WriteLine("Sent");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
}
I already have the import of
using System.Net;
using System.Net.Mail;