Solved

System.Net.Mail.SmtpException: Cannot get IIS pickup directory.

Posted on 2007-03-20
8
9,993 Views
Last Modified: 2013-11-07
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.SmtpException' occurred in System.dll
"System.Net.Mail.SmtpException: Cannot get IIS pickup directory.
   at System.Net.Mail.IisPickupDirectory.GetPickupDirectory()
   at System.Net.Mail.SmtpClient.Send(MailMessage 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_20070123.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.main.dataserv.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.com") ' To test what happens when a bad address is sent
        Mess.Attachments.Add(MessAtt)
        Mess.Subject = Subject
        Mess.Body = Body
        MailObj.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
        MailObj.UseDefaultCredentials = 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.

0
Comment
Question by:mkacos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 15

Expert Comment

by:crisco96
ID: 18762954
in your web.config in system.web add the key:
<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.
0
 
LVL 1

Author Comment

by:mkacos
ID: 18763787
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.  




0
 
LVL 15

Expert Comment

by:crisco96
ID: 18763917
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.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Author Comment

by:mkacos
ID: 18764176
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.
0
 
LVL 1

Author Comment

by:mkacos
ID: 18766606
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.PickupDirectoryLocation = "\\Isasrv\PickUp2"
MailObj.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory

FYI: On the older machine, using MailObj.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis the emails did not send for hours.  Using SmtpDeliveryMethod.SpecifiedPickupDirectory they send immeadiatly
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19098386
PAQed with points refunded (500)

Computer101
EE Admin
0
 

Expert Comment

by:ReallyGoodStuff
ID: 29925328
Why does the accepted answer say "PAQed with points refunded (500)

Computer101
EE Admin"

I need an answer to this as well?
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
"lblTime is not declared" 3 65
reading an excel file vb.net 2 47
.NET Redemption/Outlook Examples 3 35
How do i create a simple array in a public class? 6 38
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question