Michael Kacos
asked on
System.Net.Mail.SmtpException: Cannot get IIS pickup directory.
Help!!!
I setup a new computer for my development. I re-installed VS2005 and the service pack. All Windows XP updates have been applied. I am now getting the following error when I try to send e-mail.
A first chance exception of type 'System.Net.Mail.SmtpExcep tion' occurred in System.dll
"System.Net.Mail.SmtpExcep tion: Cannot get IIS pickup directory.
at System.Net.Mail.IisPickupD irectory.G etPickupDi rectory()
at System.Net.Mail.SmtpClient .Send(Mail Message message)
at ITCClass.ITCCom.DoEmail() in C:\DotNetProjects\ITCClass \ITCClass\ ITCCom.vb: line 586"
Here is the code:
Public Sub DoEmail()
Dim MAdd As String = "me@us.com"
Dim FromAdd As New MailAddress(MAdd)
Dim Attach As String = "c:\export\RMDSAPAR_200701 23.txt" ' Test for an attachment
Dim MessAtt As New Attachment(Attach)
Dim x As String, EMailSuccess As String
Dim MailObj As New System.Net.Mail.SmtpClient ("isasrv.m ain.datase rv.net")
Dim Mess As New MailMessage
Dim Subject As String, Body As String, Username As String
FromAdd.Address.Insert(0, "me@us.com")
Subject = "Test E-mail"
Body = "This is a test e-mail"
Mess.From = FromAdd
Mess.To.Add("me@us.com")
Mess.To.Add("bad_add@us.co m") ' To test what happens when a bad address is sent
Mess.Attachments.Add(MessA tt)
Mess.Subject = Subject
Mess.Body = Body
MailObj.DeliveryMethod = SmtpDeliveryMethod.PickupD irectoryFr omIis
MailObj.UseDefaultCredenti als = True
Try
MailObj.Send(Mess)
Catch ex As Exception
x = ex.ToString
EMailSuccess = x
End Try
End Sub
This worked like a champ on my old computer but fails on the new one. I am using the same user account on both and am connected to the same network. I have looked and cannot find a resonable solution.
I setup a new computer for my development. I re-installed VS2005 and the service pack. All Windows XP updates have been applied. I am now getting the following error when I try to send e-mail.
A first chance exception of type 'System.Net.Mail.SmtpExcep
"System.Net.Mail.SmtpExcep
at System.Net.Mail.IisPickupD
at System.Net.Mail.SmtpClient
at ITCClass.ITCCom.DoEmail() in C:\DotNetProjects\ITCClass
Here is the code:
Public Sub DoEmail()
Dim MAdd As String = "me@us.com"
Dim FromAdd As New MailAddress(MAdd)
Dim Attach As String = "c:\export\RMDSAPAR_200701
Dim MessAtt As New Attachment(Attach)
Dim x As String, EMailSuccess As String
Dim MailObj As New System.Net.Mail.SmtpClient
Dim Mess As New MailMessage
Dim Subject As String, Body As String, Username As String
FromAdd.Address.Insert(0, "me@us.com")
Subject = "Test E-mail"
Body = "This is a test e-mail"
Mess.From = FromAdd
Mess.To.Add("me@us.com")
Mess.To.Add("bad_add@us.co
Mess.Attachments.Add(MessA
Mess.Subject = Subject
Mess.Body = Body
MailObj.DeliveryMethod = SmtpDeliveryMethod.PickupD
MailObj.UseDefaultCredenti
Try
MailObj.Send(Mess)
Catch ex As Exception
x = ex.ToString
EMailSuccess = x
End Try
End Sub
This worked like a champ on my old computer but fails on the new one. I am using the same user account on both and am connected to the same network. I have looked and cannot find a resonable solution.
ASKER
Crisco
Thanks for the response but it opens more questions.
I added the Identity Impersonate to the new computer and it did not work. I did not change the IIS config because the older machine works with the current settings.
I have compaired the web.config file on the old computer and the new one. They are the same. The old one does NOT have the identity impersonate entry in it yet it works.
Thanks for the response but it opens more questions.
I added the Identity Impersonate to the new computer and it did not work. I did not change the IIS config because the older machine works with the current settings.
I have compaired the web.config file on the old computer and the new one. They are the same. The old one does NOT have the identity impersonate entry in it yet it works.
My guess is that the current user that the site runs under (with the new computer) doesn't have permissions to do what you're trying.
Using identity impersonate and an anonymous user that definitely has access to the pickup folder would either confirm or reject my suspicion.
Using identity impersonate and an anonymous user that definitely has access to the pickup folder would either confirm or reject my suspicion.
ASKER
The site is on a seperate server, it is not on the new machine. The only change is the new workstation. The IIS server is the same as before and is a production server.
FYI: The user ID on the workstation is an administrator for the network. The only obvious change is the new workstation name.
FYI: The user ID on the workstation is an administrator for the network. The only obvious change is the new workstation name.
ASKER
After fixing an issue with our firewall that would not let me get to the pikcup directory, I changed the code to the following and it works.
MailObj.PickupDirectoryLoc ation = "\\Isasrv\PickUp2"
MailObj.DeliveryMethod = SmtpDeliveryMethod.Specifi edPickupDi rectory
FYI: On the older machine, using MailObj.DeliveryMethod = SmtpDeliveryMethod.PickupD irectoryFr omIis the emails did not send for hours. Using SmtpDeliveryMethod.Specifi edPickupDi rectory they send immeadiatly
MailObj.PickupDirectoryLoc
MailObj.DeliveryMethod = SmtpDeliveryMethod.Specifi
FYI: On the older machine, using MailObj.DeliveryMethod = SmtpDeliveryMethod.PickupD
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why does the accepted answer say "PAQed with points refunded (500)
Computer101
EE Admin"
I need an answer to this as well?
Computer101
EE Admin"
I need an answer to this as well?
<identity impersonate="true" />
Then in IIS configure your anonmyous user to be a user that has access to the pickup directory on your email server.