The IIS provider doesn't expose an enumerator interface for this entry, use the 
property names directly like this:

...
  DirectoryEntry mailSvc = new DirectoryEntry("IIS://localhost/SmtpSvc/1");
  PropertyCollection pcoll = mailSvc.Properties;
  Console.WriteLine(pcoll["DropDirectory"].Value);
  Console.WriteLine(pcoll["QueueDirectory"].Value);
  Console.WriteLine(pcoll["BadMailDirectory"].Value);
  Console.WriteLine(pcoll["PickupDirectory"].Value);
  mailSvc.Dispose();
...

Willy.


----- Original Message -----
From: "Alex Henderson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 26, 2002 2:41 AM
Subject: [DOTNET] Directory Services : accessing IIS SMTP server details.


> I'm working on a simple application that needs to view the queue of the IIS
> SMTP server ie. The list of files in the C:\Inetpub\mailroot\Queue
> directory... Now I want to retrieve the location of the queue directory
> programmatically from IIS using ADSI (using the QueueFolder property which I
> think exists?)
>
> I decided to use directory services in .Net with poor results (I've never
> used them before). I can't seem to get a list of properties for the object
> though (it's as if the properties aren't exposed in .Net at all)
>
> Here's the code snippet:
>
> smtpServiceEntry = new DirectoryEntry("IIS://localhost/SMTPSVC/1");
> // will fail on the next list and debug reveals that there are no property
> values
> // at all.
> foreach (string propName in smtpServiceEntry.Properties.PropertyNames)
> {
>         Console.WriteLine("propName: " + propName);
> }
>
> As a background to this, originally I based it on some source code I had
> from a while back (written in horrible ASP by someone else...):
>
> <%
> Dim fso, f, f1, fc, s, IIsObj
> Set IIsObj = GetObject("IIS://LocalHost/SMTPSVC/1")
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.GetFolder(iisobj.QueueFolder)
> Set fc = f.Files
>
> Count = 0
> For Each f1 in fc
>     s = s & f1.name
>     s = s & "<BR>"
>    Count= Count+1
> Next
> Msgbox "There are " & Count & " Files in the Queue Folder" & vbcrlf & s
> %>
>
> Any know what I'm doing wrong (or another way to do this in .Net?) any help
> would be much appreciated.
>
> - Alex
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to