Thursday 2 June 2016

send simple gmail email in c#

Hi all.. Once agian today I have a small code sample for you..
This code describes how to send an email using c#


MailMessage mail = new MailMessage("you@yourcompany.com","user@domain.com");
SmtpClient client = new SmtpClient();            
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.gmail.com";

mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);

No comments:

Post a Comment