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 .
I was having this same error on Windows 7 with code that worked fine on XP. After much trial and error. I setup IIS to store mail in a pickup directory. But I still had the error.
In my code I commented out the line:
client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
Removing this line of code worked, not sure why. Hope it works for you too because this issue is a real time waster to troublshoot.
I did NOT have to change any permissions on the directory. I did NOT have to modify the metabase. I did NOT have to modify the web.config (which I really didn't want to do because I only want the emails placed into a directory while I'm doing development on my local machine, not in production - I didn't want two different web.config files to maintain).
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 instead and sent the Host
and Port
properties to your SMTP server.
More information: http://forums.iis.net/p/1149338/1869548.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With