// Create a Mail Address Type Object for From Email MailAddress sFrom = new MailAddress("xyz@mail.yahoo.com", "New Message"); // Create a Mail Address Type Object for To Email MailAddress sTo = new MailAddress("abc@cherisys.com"); // Create a Mail Message Type Object for Email and assign values to various properties, like subject, body, mail type. MailMessage MyMail = new MailMessage(sFrom, sTo); MyMail.Subject = "Subject Text"; MyMail.Body = "Body Text"; MyMail.IsBodyHtml = true; MyMail.BodyEncoding = Encoding.UTF8; //Create a SMTP client type object, Protocol responsible to send emails. And add the address of your email SMTP. Example of Yahoo added. SmtpClient SmtpMail = new SmtpClient("smtp.mail.yahoo.com"); SmtpMail.EnableSsl = true; // Decline default credentials and add yours. Your Email (From Email) & Password. SmtpMail.UseDefaultCredentials = false; SmtpMail.Credentials = new System.Net.NetworkCredential("xyz@mail.yahoo.com", "xyzpassword"); // Now send email try { SmtpMail.Send(MyMail); } catch (Exception o) { }
catch
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)