November 2010 (1)
August 2010 (1)
July 2010 (1)
June 2010 (3)
July 2009 (3)
June 2009 (1)
May 2009 (1)
February 2009 (1)
January 2009 (1)
November 2008 (3)
October 2008 (4)
September 2008 (9)
August 2008 (6)
July 2008 (3)
June 2008 (3)
January 2008 (1)
November 2007 (2)
October 2007 (6)
September 2007 (5)
August 2007 (22)
July 2007 (6)
June 2007 (1)
May 2007 (3)
April 2007 (27)
March 2007 (8)
February 2007 (6)
September 2006 (2)
August 2006 (4)
July 2006 (9)
June 2006 (17)
May 2006 (20)
April 2006 (12)
March 2006 (9)
February 2006 (4)
January 2006 (3)
December 2005 (2)
November 2005 (4)
October 2005 (5)
September 2005 (37)
August 2005 (83)
July 2005 (6)

Active Directory / LDAP (0)
ASP.Net (19)
Blackberry Development (4)
c# (34)
c++ (3)
Code Camp (1)
Excel (1)
Exchange (3)
Front Page 2003 (6)
FTP User Editor (4)
IIS (146)
IIS - Log Parser (7)
IIS / FTP (12)
IIS / Tools / Administration (42)
IIS / Tools / Authentication (6)
IIS / Tools / Compression (8)
IIS / Tools / Crash & Hang (12)
IIS / Tools / ISAPI Filters (17)
IIS / Tools / Log Files (17)
IIS / Tools / Scripts (28)
IIS / Tools / Security (9)
IIS / Tools / SSL (6)
IIS 7 (3)
Internet Information Server (1)
Me (Chris Crowe) (6)
MIME Types (1)
Misc (72)
Oulook Express (2)
Silverlight (1)
SQL Server (27)
SQL Server CTE (1)
Vista (15)
Vista Gadgets (8)
Visual Studio (11)
Voice over BroadBand (1)
Windows (33)
Windows Powershell (3)
Windows Sharepoint Services (0)
Windows Sharepoint Services (15)
Windows Vista (14)
Wine Cellar (1)
WMI (8)
Exchange (3)


Reinstalling IIS on an Exchange 2000 or Exchange 2003 server

If you are running IIS on an Exchange Server 2000 or 2003 machine make sure you really think hard before you uninstall IIS - it is not a trivial process to get your exchange and IIS linked together again.

Microsoft has a KB article #320202 available here;en-us;320202 that describes the process in detail to get the system working again.

Apparently when you remove IIS you have also removed some additional configuration parameters that exchange has added to the IIS Metabase and you must follow the 6 steps below to relink the attributes when you install IIS again.

  • Back Up Data
  • Dismount the Mailbox and the Public Information Store
  • Stop Exchange Services and Remove IIS
  • Reinstall Internet Information Service and Reapply Service Packs
  • Reinstall Exchange Server
  • Restore the Original Exchange Information Store

So this is a non trivial action - just make sure you really know what you are doing prior to removing IIS and if you are going to remove IIS and follow the KB Article give yourself plenty of time...

Windows/Exchange - Email Forwarding System

EFS is "mail relay" software. It was specifically designed to give people with "part time" (dialup) connections to the Internet (or those with fulltime connections but their Internet Service Provider (ISP) does not support ETRN - which is not a protocol I recommend anyway) a way of retrieving mail from their ISP and delivering messages to an internal mail server, such as Microsoft Exchange Server, Lotus Notes 4 or 5, the freeware EMWAC IMS or in fact any RFC compliant SMTP server. You do not need a fulltime connection to the Internet to run EFS - it works with both static (full time) and dynamic (part time) IP addresses.

The best part about EFS is that once it's setup, it is basically maintenance free. Similar mail retrieval programs usually require you to add a separate mailbox for every user that mail will be distributed for - the simple downside of this, continuous maintainance and double data-entry. EFS does away with this by allowing you to specify the domain that you will be accepting mail for (just as you are required to do for your mail server). It is this "Internal routing" feature that makes EFS unique amongst most other POP3 retrievers, the ability to accept and deliver mail for your domain.

For more details see

Exchange - Using WMI to list all mailboxes and their sizes from c#

First off this is my 100th post to my blog!

This is a sample of how to talk to MS Exchange to enumerate all of the mailboxes and display them with the total message count and total message size.

It also shows examples of:

  • Creating your own table
  • Using a DataView to sort the table
  • Writing to XML from a dataset
  • Padding Strings
  • Using the System.Management namespace
using System;

namespace Sample1
    /// Summary description for Class1.

    class Class1
        /// The main entry point for the application.

        static void Main(string[] args)

                System.Console.WriteLine("Enumerate mailbox sizes in MS Exchange Server - Chris Crowe");

                // Create a DataSet (only needed if you want to save to XML )
                System.Data.DataSet ds = new System.Data.DataSet();
                // Create a DataTable to hold our results
                System.Data.DataTable dt = new System.Data.DataTable("Mailboxes");            
                // Add the table to the dataset

                // Create columns for our data
                dt.Columns.Add(new System.Data.DataColumn("Mailbox"typeof(String)));
                dt.Columns.Add(new System.Data.DataColumn("Messages"typeof(Int32)));            
                dt.Columns.Add(new System.Data.DataColumn("Size"typeof(Int32)));            

                System.Management.ConnectionOptions objconn = new System.Management.ConnectionOptions();
                objconn.Impersonation = System.Management.ImpersonationLevel.Impersonate;
                // Gets or sets a value indicating whether user privileges need to be enabled for the 
                // connection operation. This property should only be used when the operation performed 
                // requires a certain user privilege to be enabled (for example, a machine reboot).
                objconn.EnablePrivileges = true;

                // Exchange Server Name
                string cServername = "*"// YOUR EXCHANGE SERVER NAME

                // Create a management scrope into the Exchange WMI namespace
                System.Management.ManagementScope exmangescope = 
                    new System.Management.ManagementScope(@"\\" + cServername + @"\root\MicrosoftExchangeV2",objconn);
                // Create a query to get the data from the Exchange WMI
                System.Management.ObjectQuery objquery = 
                    new System.Management.ObjectQuery("SELECT * FROM Exchange_Mailbox");

                // Retrieves a collection of management objects based on the query.
                System.Management.ManagementObjectSearcher objsearch = 
                    new System.Management.ManagementObjectSearcher(exmangescope,objquery);

                // Invokes the WMI query and returns the resulting collection.
                System.Management.ManagementObjectCollection queryCollection1 = objsearch.Get(); 

                // Loop through each item in the collection
                foreach( System.Management.ManagementObject instmailbox in queryCollection1 ) 
                    // Add a row of data to our table
                    dt.Rows.Add(new object[] { 
                                                 instmailbox["size"] } );

                // Used to calculate the size of all of the mailboxes and the message count
                int TotalMessages=0;
                Int64 TotalSize=0;

                // Create a DataView to sort the data by Mailbox Size
                System.Data.DataView dv = new System.Data.DataView(dt);
                dv.Sort = "Size desc, Mailbox";

                // Write a heading
                System.Console.WriteLine(string.Format("{0} {1} {2} "
                // Write a line of dashes

                // Get an enumerator to enumate the DataView to get the rows from the table (sorted)
                System.Collections.IEnumerator enumerator = dv.GetEnumerator();            
                // Loop through each item in the table
                    // Get a row 
                    System.Data.DataRowView row = enumerator.Current as System.Data.DataRowView;

                    // Display the row
                    System.Console.WriteLine(string.Format("{0} {1} {2} Kb"

                    // Add the size and message count to our totals
                    TotalMessages += Convert.ToInt32(row["Messages"]);
                    TotalSize += Convert.ToInt64(row["Size"]);

                // Write a row of dashes

                // Write the totals
                System.Console.WriteLine(string.Format("{0} {1} {2} Kb"

                // Write the XML to a file if we want to

            // Catch any problems and show a message!
            catch(Exception e)
                System.Console.WriteLine("Error : " + e.Message.ToString());

This is how it displays its output to the console.

If you write the data to a XML file as the above example does this is how it may appear.

xml version="1.0" standalone="yes"?>
    <Mailbox>SMTP (SBS2003-{7390D6EA-A466-417D-A461-ADEA24553CB8})</Mailbox>
    <Mailbox>Chris Crowe [MVP]</Mailbox>
    <Mailbox>Pam Elston</Mailbox>
    <Mailbox>chris crowe</Mailbox>
    <Mailbox>Chris Crowe</Mailbox>
    <Mailbox>System Attendant</Mailbox>