Thought Ayman's snip was pretty cool System.net.mail with Gmail account  I hadn't looked at this part of the namespace.

Here it is with squigles, pretty much the same.

I have been unable to connect the gmail smtp server though and will show my error first...

The Error I get:

Failure sending mail.
System.Net.WebException: Unable to connect to the remote server ---> System.Net.
Sockets.SocketException: An established connection was aborted by the software i
n your host machine
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock
et 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 ow
ner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket
6, 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, GeneralAsyncD
elegate 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)

Has System.Net.NetworkCredential changed in VS 2005?

using System;

using System.Collections.Generic;

using System.Text;

using System.Net.Mail;

namespace ConsoleMailSend

{

public static class MailMaker

{

public static void sendmail()

{

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

string msgBody =string.Empty;

System.Net.Mail.SmtpClient smtp =new SmtpClient();

mail.From = new System.Net.Mail.MailAddress(@"ur-email@gmail.com", "c");

mail.To.Add(@"an-email@adomain.com");

mail.Subject = "Subject";

mail.Body = "msgBody";

mail.IsBodyHtml = true ;// This is to enable HTML in your email body

mail.ReplyTo = new MailAddress(@"ur_email@rd.com") ; // This is optional, it allows you to add Reply To email address.

smtp.Host = "smtp.gmail.com";

smtp.Port = 25;

smtp.EnableSsl = true;

smtp.Credentials = new System.Net.NetworkCredential(@"ur-email@gmail.com", "password");

try

{

smtp.Send(mail);

}

catch (System.Exception ex)

{

Console.WriteLine(ex.Message.ToString());

Console.WriteLine(ex.InnerException.ToString());

}

}

}

}