First you include System.Net.Mail name space ..
Then you insert the below query in button click event...
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress("raja.com");
message.To.Add("raja30march90@gmail.com");
message.Subject = "Subject";
message.Body = "Body Content";
SmtpClient sptclt = new SmtpClient();
sptclt.Host = "127.5.7.1";
sptclt.Send(message);
lblStatus.Text = "Mail send successfully";
}
catch (Exception e)
{
lblError.Text = "Mail sent Failed";
}
Then you insert the below query in button click event...
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress("raja.com");
message.To.Add("raja30march90@gmail.com");
message.Subject = "Subject";
message.Body = "Body Content";
SmtpClient sptclt = new SmtpClient();
sptclt.Host = "127.5.7.1";
sptclt.Send(message);
lblStatus.Text = "Mail send successfully";
}
catch (Exception e)
{
lblError.Text = "Mail sent Failed";
}
No comments:
Post a Comment