3

I've been searching for a solution for a few days now, I've looked through the MSDN for Interop.Outlook and I think I've found what I need, but can't seem to implement it properly.

Here's the code I've came up with based on something similar I saw in VBA.

class Program
{
    Stores allstores = new Stores();
    Store store;

    static void Main(string[] args)
    {
        foreach (var store in allstores)
        {
            MessageBox.Show(store.FilePath);
        }

    }
}

`

This essentially needs to cycle through a list of computers, and run this code on their outlook(some 2003, some 2007) in order to inventory all connected PST's in each outlook profile. I'm sure there's more code to this, but I can't get this portion to work at all. There seems to be a lack of information on inventorying Outlook data files, most of it is reading e-mails from the mailboxes and not the data file itself.

If someone could shed some light on what I'm overlooking, It'd be greatly appreciated.

EDIT:

I've actually made a working piece of code now, however I have a problem with compatibility. The program works as designed in Office 2010/2007, however it crashes when accessing a 2003 version. I imagine I need to use the Microsoft Office Object 11.0, however I only have Microsoft Office Object 12.0 listed - is there a way to get the 11.0 reference?

1
  • It needs to retrieve the connected file path of the PST, to clarify. Jan 16, 2012 at 16:59

2 Answers 2

0

This may be of use, pretty thorough object model comparison and development guide.

1
  • Thanks, I've actually got everything working now. The problem was "Store" does not exist in 2003, so I have to read from the StoreID and convert. Jan 17, 2012 at 17:51
0

There is no reason to actually log to any Outlook profiles (which might require an authentication prompt). All the information is already in the profile section in the registry. The exact location is Outlook version specific, and the profile section guids are generated randomly, so the documented profile management API (IProfAdmin etc.) is the way to go, but unfortunately it is Extended MAPI and requires C++ or Delphi.

As of Outlook 2007, Outlook Object Model exposes Namespace.Stores collection and Store.FilePath property, so you can loop through all stores and read the FilePath property for each store (be sure to filter out OST files).

Note that there can be multiple Outlook profiles (as shown in Control Panel | Mail | Show Profiles), but Outlook can only work with one profile at a time, so to use a different profile, you'd need to close Outlook.

If using Redemption is an option (I am its author), it includes ProfMan library (accessible in any language) which will let you extract all PST file locations from all local profiles without actually logging in.:

        'Print the path to all the PST files in all profiles
         PR_PST_PATH = &H6700001E
         set Profiles=CreateObject("ProfMan.Profiles")
         for i = 1 to Profiles.Count
           set Profile = Profiles.Item(i)
           set Services = Profile.Services
           Debug.Print "------ Profile: " & Profile.Name & " ------"
           for j = 1 to Services.Count
             set Service = Services.Item(j)
             If (Service.ServiceName = "MSPST MS") or (Service.ServiceName = "MSUPST MS") Then
                'there should be only one provider for this service
                'but we should really loop through all the providers
                Debug.Print Service.Providers.Item(1).ProfSect.Item(PR_PST_PATH)
             End If
           next
         next

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.