Categories:

The following C# source code shows how to send an email from a Gmail address using the SMTP server.

using System.Net.Mail;
MailMessage objeto_mail = new MailMessage();
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("username", "password");
objeto_mail.From = new MailAddress("from@example.com");
objeto_mail.To.Add(new MailAddress("to@example2.com"));
objeto_mail.Subject = "Subject here";
objeto_mail.Body = "Message here";
client.Send(objeto_mail);

Tags:

2 Responses

  1. I was extremely pleased to discover this great site. I want to to thank you for ones time just for this wonderful read!! I definitely liked every little bit of it and i also have you bookmarked to look at new information in your blog.

Leave a Reply

Your email address will not be published. Required fields are marked *