tags:

views:

1295

answers:

2

Hi, I’ve been using the Smtp server 127.0.0.1 .The error I get:

System.Net.Mail.SmtpException: Cannot get IIS pickup directory.at System.Net.Mail.IisPickupDirectory.GetPickupDirectory().

This Error occured ,when Email send from ASP web page.But EMail send from ASP.NET page,error is not occurred. Plz help .

+3  A: 

Unfortunately, this exception is raised when any kind of problem occurs while trying to determine the location of IIS/SMTP pickup directory. A common cause is missing IIS SMTP service.

If you are sending mail using System.Net.Mail.SmtpClient, try setting the pickup directory manually:

// C#
var client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = ...;
client.Send(...);

Or set this in ASP.NET's Web.config instead:

<configuration>
    <system.net>
        <mailSettings>
            <smtp deliveryMethod="SpecifiedPickupDirectory">
                <specifiedPickupDirectory
                    pickupDirectoryLocation="..." />
                <network defaultCredentials="false" />
            </smtp>
        </mailSettings>
    </system.net>
</configuration> 

Alternatively, use SmtpDeliveryMethod.Network method instad and sent the Host and Port properties to your SMTP server.

More information: http://forums.iis.net/p/1149338/1869548.aspx

Lukas Pokorny
+1  A: 

The pickup directory is stored in the II6 Metabase, so if the account that your web-app runs as does not have access to the required nodes, this error can be thrown (had this myself). Metabase permissions are seperate from file permissions, so you explore it with Metabase explorer:

http://www.microsoft.com/downloads/details.aspx?FamilyID=56fc92ee-a71a-4c73-b628-ade629c89499&amp;displaylang=en (its part of the IIS resource kit)

These nodes need to have read permission given to your web-app user: \LM\SmtpSvc \LM\SmtpSvc\1

JonoW