Neelam Sharma
Neelam Sharma

Reputation: 2855

Failed to send email due to IIS pickup directory

We are working on project that send email using System.Net.Mail.SmtpException.

     SmtpClient client = new SmtpClient("127.0.0.1");

                    if (ConfigSetting.Is2008 || ConfigSetting.IsLocal)
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    else
                        client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
 client.Send(message);

client.Send(message) throwing these two exceptions :

1. If sending to local server then getting exception :

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

2. And on sending email using our configuration then facing this exception :

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

I have done setting at IIS Manager in SMTP E-mail for : Store e-mail in a pickup directory

OR added manually :

client.PickupDirectoryLocation = "C:\\Users\\Admin\\Desktop\\EmailLocation";

But nothing resolved for error : System.Net.Mail.SmtpException: Cannot get IIS pickup directory.

I am working on :

  1. OS : Windows-8.1
  2. IIS : Version-6

Upvotes: 1

Views: 1515

Answers (1)

regisbsb
regisbsb

Reputation: 3814

Change to System.Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory

Upvotes: 0

Related Questions