清点连接到 Outlook 的 PST 远程计算机?

发布于 2024-12-27 02:14:34 字数 761 浏览 1 评论 0 原文

我已经寻找解决方案几天了,我浏览了 MSDN 的 Interop.Outlook,我想我已经找到了我需要的东西,但似乎无法正确实现它。

这是我根据在 VBA 中看到的类似内容编写的代码。

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

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

    }
}

`

这本质上需要循环浏览计算机列表,并在其 Outlook(一些 2003 年,一些 2007 年)上运行此代码,以便在每个 Outlook 配置文件中清点所有连接的 PST。我确信还有更多代码,但我根本无法让这部分工作。似乎缺乏有关清点 Outlook 数据文件的信息,其中大部分是从邮箱中读取电子邮件而不是数据文件本身。

如果有人能够阐明我所忽略的内容,我将不胜感激。

编辑:

我现在实际上已经编写了一段工作代码,但是我有兼容性问题。该程序按照 Office 2010/2007 中的设计运行,但在访问 2003 版本时会崩溃。我想我需要使用 Microsoft Office Object 11.0,但我只列出了 Microsoft Office Object 12.0 - 有没有办法获取 11.0 参考?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墟烟 2025-01-03 02:14:34

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

爱*していゐ 2025-01-03 02:14:34

没有理由实际登录到任何 Outlook 配置文件(这可能需要身份验证提示)。所有信息都已在注册表的配置文件部分中。确切位置特定于 Outlook 版本,并且配置文件部分 guid 是随机生成的,因此记录的配置文件管理 API (IProfAdmin 等)是可行的方法,但不幸的是它是扩展 MAPI 并且需要 C++ 或 Delphi。

从 Outlook 2007 开始,Outlook 对象模型公开 Namespace.Stores 集合和 Store.FilePath 属性,因此您可以循环遍历所有存储并读取 FilePath > 每个商店的属性(请务必过滤掉 OST 文件)。

请注意,可以有多个 Outlook 配置文件(如控制面板 | 邮件 | 显示配置文件中所示),但 Outlook 一次只能使用一个配置文件,因此要使用不同的配置文件,您需要关闭 Outlook。

如果使用兑换是一个选项(我是它的作者),它包括ProfMan 库(可以任何语言访问),它可以让您从所有本地配置文件中提取所有 PST 文件位置,而无需实际登录:

        '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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文