@manhnguyenv

Welcome to my blog!

How to send email from C#

April 25, 2018 22:28

How to send email from C#

http://csharp.net-informations.com/communications/csharp-smtp-mail.htm

https://stackoverflow.com/questions/9201239/send-e-mail-via-smtp-using-c-sharp

 

using System.Net.Mail;

...

MailMessage mail = new MailMessage("you@yourcompany.com", "user@hotmail.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);

Categories