I want to send a confirmation email to user in registration page. The following code is the related part:

```
try
{
    SmtpClient sc = new SmtpClient();
    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
    string Ema = u.UserMail.ToString();
    MailAddress gonderen = new MailAddress("admin@gmail.com", "Hello");
    sc.Host = "smtp.gmail.com";
    sc.Port = 587;
    mail.To.Add(Ema);
    mail.Subject = "Confirmation Message";
    mail.From = gonderen;
    mail.IsBodyHtml = true;
    mail.BodyEncoding = System.Text.Encoding.GetEncoding("ISO-8859-9");
    mail.Body = "<html><body>";
    sc.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
    sc.Send(mail);
    MESSAGE(true, "Sending mail is successful");
}
catch (Exception)
{
    MESSAGE(true, "Sending mail is unsuccessful!");
}

```

But it does not send an email to related user. I have looked at forums and I added to web.config the following part:

```
  <system.net>
    <mailSettings>
      <smtp from="myaddress@gmail.com ">
        <network host="smtp.gmail.com" defaultCredentials="false"
      port="587" userName ="myaddress@gmail.com" password="password" />
      </smtp>
    </mailSettings>
  </system.net>

```

But anything didn't change. Then i have debugged and it enters into the try statement and when it comes to `sc.Send(mail);`, it drops to catch. Where is my mistake?

Additionally, during debug i realized that it shows this error: `cannot get IIS pickup directory`. I have controlled whether I have a smtp service or not from services but i couldn' t see this service. Is this error related to that service?

Thanks in advance.