Send Email using smtpClient
We can send the email using the smtpclient.
The following code will explain how to send the email using smtpclient
Following namespace is used to send email
using System.Net.Mail;
MailMessage MyMailMessage = new MailMessage();
MyMailMessage.Subject = "My Subject";
MyMailMessage.To.Add("To Address ");
MyMailMessage.From = new System.Net.Mail.MailAddress("My From AddressP".Replace("[",
"<").Replace("]", ">"));
Message.Body = " Email Body Content";
SmtpClient MySmtpClient = new SmtpClient("MailServer", 25);
MySmtpClient.Send(Message);
Code Explanation
1. Create the instance of "MailMessage".
2. Fill the properties.
3. Create instance of SmtpClient for the mail server.
4. Send the "MailMessage" through "SmtpClient".
By
Nathan
