Thursday, August 9, 2018

Sending Email in C

Sending Email in C



 SmtpClient client = new SmtpClient();
                client.Port = 25;
                client.Host = "smtp.gmail.com";
                client.EnableSsl = true;
                client.Timeout = 10000000;
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials = new System.Net.NetworkCredential("asad.naeem@gmail.com", "Password");
//  MailMessage mm = new MailMessage("asad.naeem@gmail.com", "asad.naeem@gmail.com", "test", "test");


                MailMessage mm = new MailMessage("FromEmail", "ToEmail", "Subject", "Body");


                mm.BodyEncoding = UTF8Encoding.UTF8;
                mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                client.Send(mm);
         
                MessageBox.Show("Email Sent");


go to link download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.