title: Failure sending mail Exception while send with SmtpClient
body: <p>C# I am trying to send mail with following code. OS is windows 2008 server. SMTP is installed.</p>
  
  <pre><code>           MailMessage message = new MailMessage();
              string[] recipientslist = recipients.Split(';');
              foreach (string recipient in recipientslist)
              {
                  if (!String.IsNullOrEmpty(recipient))
                  {
                      System.Net.Mail.MailAddress mailAddress = 
                          new System.Net.Mail.MailAddress(recipient);
                      message.To.Add(mailAddress.Address);
                  }
              }
              message.From = new MailAddress(sender);
              message.Subject = subject;
              message.Body = body;
              SmtpClient smtpClient = new SmtpClient();
      smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
      smtpClient.UseDefaultCredentials = true;
      smtpClient.Send(message);
  </code></pre>
  
  <p>In web.config</p>
  
  <pre><code>  &lt;system.net&gt;
      &lt;mailSettings&gt;
        &lt;smtp deliveryMethod="PickupDirectoryFromIis"&gt;
          &lt;network host="localhost" port="25" defaultCredentials="true" /&gt;
        &lt;/smtp&gt;
      &lt;/mailSettings&gt;
    &lt;/system.net&gt;
  </code></pre>
  
  <p>Even smtp is installed,
  I m getting Exception: Failure sending mail.
  Stack Trace:    at System.Net.Mail.SmtpClient.Send(MailMessage message)....</p>
  
  <p>==========================================================================================</p>
  
  <p>The other scenario when SMTP is not installed, it giving me the exception <strong>Cannot get IIS pickup directory</strong></p>
  
  <p>Any help is highly appreciable.</p>
  
  <p>Thanks*<em>strong text</em>*</p>