I\'m having trouble sending email using my gmail account. Im pulling my hair out.
The same settings work fine in Thunderbird.
Here\'s the code. I\'ve also tr
You won't belive what fixed my problem.
The Credentials property
ss.Credentials = new NetworkCredential("username", "pass");
must be declared after
ss.UseDefaultCredentials = false;
So the final working code listing is
SmtpClient ss = new SmtpClient("smtp.gmail.com", 587);
ss.EnableSsl = true;
ss.Timeout = 10000;
ss.DeliveryMethod = SmtpDeliveryMethod.Network;
ss.UseDefaultCredentials = false;
ss.Credentials = new NetworkCredential("username", "pass");
MailMessage mm = new MailMessage("donotreply@domain.com", "destination@domain.com", "subject here", "my body");
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
ss.Send(mm);
Is this a bug?