TO Run this program you need 1> A email id
2>Password of email id
3>Your SMTP host (ex-for gmail- smtp.gmail.com)
Now you can use this function given----
add these name space--
using System.Net.Mail;
using System.Web;
copy and paste this function and use it easily.
public static bool SendMail(string fromAddress, string toAddress, string subject, string body)
{
MailMessage msgMail = new MailMessage(fromAddress, toAddress, subject, body);
msgMail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp host name";
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential("your email id", "password");
try
{
smtp.Send(msgMail);
return true;
}
catch
{
return false;
}
}
OR YOu CAN TRY....
MailMessage mail = new MailMessage();
mail.Subject = "Test Email";
string Body = "<b>Welcome Varanasiworld!!</b>";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("EMAIL", "Pass");
smtp.EnableSsl = true;
smtp.Send(mail);
Some SMTP Hosts::---