1

so here is my code:

   protected void BtnSubmit_Click(object sender, EventArgs e)
    { 
        MailMessage msg = new MailMessage();
        msg.From = new MailAddress("[email protected]","Kamal");
        msg.To.Add(TxtEmailPass.Text);
        msg.Subject = "Forget Password!";
        msg.Body = "your password is:";
        SmtpClient mySmtpClient = new SmtpClient();
        mySmtpClient.Host = "www.Hotmail.com";
        NetworkCredential nc = new NetworkCredential();
        nc.UserName = "[email protected]";
        nc.Password = "";
        mySmtpClient.UseDefaultCredentials = true;
        mySmtpClient.Credentials = nc;
        mySmtpClient.Port = 587;
        mySmtpClient.EnableSsl = true;

        mySmtpClient.Send(msg);


    }

it keeps telling me that

"No connection could be made because the target machine actively refused it 157.56.198.204:587"

anyone can help me with this?

1
  • IMHO Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port, this may be because it is not running at all or because it is listening on a different port. Commented Mar 29, 2015 at 6:45

2 Answers 2

1

Your host address is wrong. you have used "www.Hotmail.com".

mySmtpClient.Host = "www.Hotmail.com";

Try this SMTP settings for your Hotmail account:

  • Hotmail SMTP server name: smtp.live.com

  • Hotmail SMTP port: 25 or 465

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

Comments

0

If you are using Microsoft Outlook & the Outlook Connector, you can define your Hotmail account just like any regular POP3 email account:

Hotmail Incoming Mail Server (POP3) - pop3.live.com (logon using Secure Password Authentification - SPA, mail server port: 995)

Hotmail Outgoing Mail Server (SMTP) - smtp.live.com (TLS enabled, port 587)

See Incoming and Outgoing Mail Server Settings for Hotmail, Yahoo! Mail, GMail, MSN, AOL and more

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.