Unable to send smtp email - error: Cannot get IIS pickup directory.

Discussion in 'ASP.NET 2.0' started by alanfawcett, Aug 11, 2007.

  1. I keep getting the "Cannot get IIS pickup directory." error. The only fix I've seen on the forum is make sure Host is set to "localhost", but I'm still getting the error. Any help would be appreciated.

    Here's the code:

    MailMessage msg = new MailMessage();
    msg.IsBodyHtml = false;
    msg.BodyEncoding = Encoding.Default;
    msg.From = new MailAddress("[email protected]");
    msg.To.Add(new MailAddress("[email protected]"));
    msg.Subject = "test";
    msg.Body = "test";
    SmtpClient smtpClient = new SmtpClient();
    smtpClient.Host = "localhost";
    smtpClient.Send(msg);
     
  2. Make sure you are not specifying the pickup directory anywhere else.You can also set the following property in your code:

    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. I added the line

    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

    and now it works.

    Thank you.
     

Share This Page