Possible Duplicate:
Sending email through Gmail SMTP server with C#
The following is the asp code triggered by a button click. I am working on windows 7 home premiun. I get the error 'The operation has timed out' have also tried port 587 but get the error 'The SMTP server requires a secure connection or the client was not authenticated. '
public void SendEmailFromCommAgent(string subject, string body, string to)
{
try
{
SmtpClient mc = new SmtpClient("smtp.gmail.com",465);
MailMessage msg = new MailMessage("xxxxxxx@gmail.com", to, subject, body);
mc.EnableSsl = true;
mc.UseDefaultCredentials = false;
mc.Credentials = new System.Net.NetworkCredential("xxxxxxxxxxxx@gmail.com", "xxxxxxxxxxxxxxx");
msg.From = new MailAddress("xxxxxxxxxxx@gmail.com");
mc.DeliveryMethod = SmtpDeliveryMethod.Network;
mc.Timeout = 50000;
msg.IsBodyHtml = true;
mc.Send(msg);
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
IIS configuration email adddress: xxx@gmail.com smtp server : smtp.gmail.com port : 465 specify credentials: username xxxxx@gmail.com password xxxxxxx
any help would be great :)