Cannot get IIS pickup directory

Discussion in 'ASP.NET 2.0' started by snapwirecou, Aug 3, 2008.

  1. Hi,

    Has anyone seen this problem before when attempting to send an email after a page has been submitted?

    "Cannot get IIS pickup directory."

    I'm using C#, the SMTP classes andusing localhost as the server...i've tried adding the smtp network credentials but this has not fixedthe problem- any ideas?

    Also, the functionality works in development although the receiving email address does put it into the spam folder!

    Thanks
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    I think you incorrectly set the send using property. pls post the code snippet.


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. MailMessage mail = new MailMessage();


    mail.To.Add(email);


    mail.Subject = subject;


    mail.From = from;


    mail.Body = body;


    mail.IsBodyHtml = isHtml;


    smtpClient = new SmtpClient(smtp);


    smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;


    smtpClient.Credentials = new System.Net.NetworkCredential(<username>, <password>);


    smtpClient.Send(mail);





    This code sends an email from my development server so the functionality is correct, i think it may be something to do with IIS configuration although i'm not sure what.


    Appreciate your help
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    Change to the following





    smtpClient = new SmtpClient(smtp);


    smtpClient.Host = "localhost"


    smtpClient.Send(mail);


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. The smtp parameter has already been assigned the value of localhost and passing it into the constructor has the same effectas assigning host directly.

    The code works on my machine and i can successfully receive an email. The same code throws an exception regarding the IIS Pickup Directory when loaded onto the discountasp server.
     
  6. Bruce

    Bruce DiscountASP.NET Staff

    You need to omit this line


    smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. Bruce

    Bruce DiscountASP.NET Staff

  8. I've made the change - now the website posts the page without any errors being reported.However, I am still not receiving the email....[​IMG]
     
  9. Nevermind....it's working, just took a litlle longer than expected to come through - [​IMG]


    Thanks for your help Bruce
     

Share This Page