You have to add the following codes to send a mail as simple as possible...
[Example is given for gmail account.
That means you have to have one gmail account to send a mail to any address.]
string pweda = "FromMailPassword";
string from = "FromYourmail@gmail.com";
string to = "abc@gef.com";
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(from);
mail.Subject = "This is a test mail";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "Test Mail.";
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(from, pweda);
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
try
{
client.Send(mail);
Response.Write("Message Sent...");
}
catch (Exception ex)
{
Exception ex2 = ex;
string errorMessage = string.Empty;
while (ex2 != null)
{
errorMessage += ex2.ToString();
ex2 = ex2.InnerException;
}
HttpContext.Current.Response.Write(errorMessage);
}
You can send from any mail address if you have any other...
Just replace with the credentials and port and host names which you can get easily get from google.
You can send anything by assigning value to 'mail.Body'.
Add this code where ever you want send the mail...
Happy coding........