Sending Autoamtic Email
Hai
I 'm encountering some problem when i tried to send the email using following code:-
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net;
using System.Net.Mail;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//Create a new MailMessage object and specify the "From" and
"To" addresses
MailMessage Email = new MailMessage
("my_email_id@gmail.com",TextBox1.Text);
Email.Subject = "test subject";
Email.Body = "this is a test";
SmtpClient mailClient = new SmtpClient();
//This object stores the authentication values
NetworkCredential basicAuthenticationInfo = new
NetworkCredential("my_email_id@gmail.com",
"my gmail password");
//Put your own, or your ISPs, mail server name on this next
// line
mailClient.Port = 465;
mailClient.Host = "smtp.gmail.com";//
"smtp.gmail.com"
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = basicAuthenticationInfo;
mailClient.Send(Email);
}
}
//Text box "TextBox1" contains the email id i'm sending the mail to
The problem i'm encountering is:-
"The remote name could not be resolved: 'smtp.gmail.com"
Plz help me out as soon as possible!!!!!
|