operation timed out>
error.
As iAs it is a simple program to test a simple mail, I am not taking any input from user. I have used simple body
and subject. I have run this and got a mail into my inbox of yahoo.
Just create a new ASP.NET page and place a button on it. Write code for ong>click
event of that button. To test it, just
run the page and click on the button. If you see no errors, it means message is sent successfully.
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;
public partial class SendMail : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage m = new MailMessage("srikanthpragada@gmail.com", "srikanthpragada@yahoo.com");
m.Body = "Testing Mail From Gmail.com";
m.IsBodyHtml = false;
m.Subject = "Testing";
m.Priority = MailPriority.High;
// SMTP settings
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); // server name and port number
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential ("srikanthpragada@gmail.com","password");
smtp.Send(m);
}
}pre>