HI
Could anybody please give me a reference or a description about how to send an Email, using my gmail account, from my asp.net web site. I've tried code in this reference.
http://www.aspdotnetfaq.com/Faq/How-to-send-HTML-Email-from-ASP-NET-using-your-Gmail-account.aspx

But its not working.
It gives an exception "failure sending mail"

Please help me
Thank you.

Use classes of System.Net.Mail namespace.

....
try
{
    System.Net.Mail.MailMessage mm=new System.Net.Mail.MailMessage("to@aaa.com","aaa@gmail.com");

   mm.Subject = "Subject details";
   mm.Body = "Sample...";

   SmtpClient sc = new System.Net.Mail.SmtpClient();
   System.Net.NetworkCredential auth = new  System.Net.NetworkCredential("your@gmail.com", "your_pass");

   sc.Host = "smtp.googlemail.com";
   sc.Port = 587;
   sc.UseDefaultCredentials = false;
   sc.Credentials = auth;
   sc.EnableSsl = true;
   sc.Send(mm);

   Response.Write( "your mail has been sent successfully..");
   }catch (Exception ex)
    {
            Response.Write(ex);
     }
.....

dear adatapost,
thank you very much for the reply
I tried this but still it does not work......
here is the exception please give me an idea.

your mail has been sent successfully..System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable host 74.125.155.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at _Default.Button1_Click(Object sender, EventArgs e) in d:\email\Default.aspx.cs:line 39
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.