0

Possible Duplicate:
Sending email in .NET through Gmail

hello,

Im using code like below but I get an error:

"Unable to connect to the remote server" MailMessage mail = new MailMessage(); mail.To.Add("[email protected]"); mail.From = new MailAddress("[email protected]"); mail.Subject = "Test Email"; string Body = "<b>Welcome to CodeDigest.Com!!</b>"; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "myPass"); smtp.EnableSsl = true; smtp.Send(mail); 
2
  • 3
    The code looks good. There's a good chance your firewall is blocking outgoing requests on that port. Commented May 4, 2011 at 13:45
  • Try using port number 465 for SSL connection. Commented Jan 2, 2014 at 13:24

1 Answer 1

3

You're not sending from the same email address you're authenticating with... You must add [email protected] as the "from"

EDIT:As Bala R suggested, probably your firewall based on the error you get

Sign up to request clarification or add additional context in comments.

1 Comment

@gruber probably the firewall

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.