Sending Email - Error
<p>I am trying to send email using the following piece of code in Winforms app.
Username and Password are correct and real- but have masked in the code.</p>

<p>I don't know wheather my local machine has the capacity to send emails or not?</p>

<p>But please advise me , What do I need to look at my machine Configuration(in IIS)?</p>

<p>ERROR: "No connection could be made because the target machine actively refused it 209.85.143.109:587"</p>

<pre><code>//All Variable Declarations
String senderAddress = string.Empty;
String receiveraddress = string.Empty;
String emailSubject = string.Empty;
String emailMessageText = string.Empty;
MailMessage mail = new MailMessage();
SmtpClient client = new SmtpClient("smtp.gmail.com",587);


private void btnEmail_Click(object sender, EventArgs e)
{

      try
      {
            //Get the Values of Controls

            senderAddress = txtSenderEmail.Text;
            receiveraddress = txtReceiverEmail.Text;
            emailSubject = txtSubject.Text;
            emailMessageText = txtMessageBody.Text;

            //Pass the Values
            mail.From = new MailAddress(senderAddress, "xxxxxxxxxx", System.Text.Encoding.UTF8);
            mail.To.Add(receiveraddress);
            mail.Subject = emailSubject;
            mail.Body = emailMessageText;
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential("xxxxxxx@gmail.com", "xxxxxx");
            client.EnableSsl = true;
            client.Send(mail);
            System.Windows.Forms.MessageBox.Show("Email Sent Successfully");



      }
      catch (Exception mailException)
      {
            System.Windows.Forms.MessageBox.Show("Message Not Sent ,Error:   " + mailException.Message);
            throw;
      }
      finally
      {

      }



}
</code></pre>

<p>I have done a telnet for both the ports and the error comes is : Could not open connection to the host. </p>

<p>Please look at the following pic, it should give you more clarity,</p>

<p><img src="http://i.stack.imgur.com/egcno.gif" alt="enter image description here"></p>
