Loading ...

Email Sending through ASP.NET | CodeAsp.Net

Email Sending through ASP.NET

 /5
0 (0votes)

 

How to send the email through asp.net is very usefull in every web application.so that i want to give some code by which you are easily send mail.

Email sending through asp.net is described below:

 

public void sendMail(string email, string name, string Password)
{
try
{
string from = "xyz@abc.com";
string MailTo = email;
string title = "Email title";
string sBody = "Dear <b>" + name + "</b>,<p>Please find attached your log-in details : </p>
  <p>Login Name: " + email + " <br>Password: " + decrypt_password(Password) + "";
sBody = sBody + "<p><br>Kindest regards,<br>Team</p>";

System.Net.Mail.SmtpClient eMail = new System.Net.Mail.SmtpClient();
eMail.Host = "Your Server's IP Address";
eMail.Credentials = new System.Net.NetworkCredential("passwordrecovery", "credential");
System.Net.Mail.MailMessage Mail = new System.Net.Mail.MailMessage(from, MailTo, title, sBody);
Mail.IsBodyHtml = true;
eMail.Send(Mail);
}

catch (Exception ex)
{
Response.Write(ex.Message.ToString());
Response.End();
}


}

simply call the method where you want to sending email with required paramter.


Hope this will help.

Comments (2)

   
Shaitender
Nice post
2/26/2009
 · 
by
   
sgfsg
gdf
3/28/2009
 · 
by

Top Posts