Email through SMTP Client (ASP.NET/C#)

Yes,it is easy to send email in .Net application through SMTP Client.First you have add
using System.Net.Mail; namespace should be added in your application.

using System.Net.Mail; //namespace

SmtpClient smtpClient = new SmtpClient("", 587);

System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential("", "yourgmailpassword");

MailMessage message = new MailMessage();

MailAddress fromAddress = new MailAddress(""iyen");
// Enable SSLsmtpClient.EnableSsl = true;

smtpClient.UseDefaultCredentials = false;

smtpClient.Credentials = mailAuthentication;
////From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddressmessage.To.Add(;

message.Subject = "Test Mail from C# Application";

message.IsBodyHtml = false;
//// Message body content
message.Body = "Nice C# function"
//// Send SMTP mail
MessageBox.Show("Email successfully sent.");
catch (Exception ex)

MessageBox.Show("Send Email Failed");

Before run this program check your are given
Vaild , yourgmailpassword and vaild

No comments: