【问题标题】:Outlook Interop: Password protected PST file headacheOutlook 互操作:受密码保护的 PST 文件令人头疼
【发布时间】:2010-03-05 21:52:55
【问题描述】:

好的,我在 C# 应用程序中使用 Outlook 互操作程序集识别 .PST 文件没有问题。但是,一旦我点击了受密码保护的文件,系统就会提示我输入密码。 我们正在我们的组织中禁用 PST 的使用,其中一个步骤是从用户的 Outlook 配置文件中卸载 PST 文件。 我需要让这个应用程序静默运行而不提示用户。有任何想法吗?有没有办法在没有 UI 的情况下创建 Outlook.Application 对象,然后尝试在受密码保护的文件上捕获异常?

// create the app and namespace
Application olApp = new Application();                
NameSpace olMAPI = olApp.GetNamespace("MAPI");
// get the storeID of the default inbox
string rootStoreID = olMAPI.GetDefaultFolder(OlDefaultFolders.olFolderInbox).StoreID;
// loop thru each of the folders
foreach (MAPIFolder fo in olMAPI.Folders)
{
    // compare the first 75 chars of the storeid
    // to prevent removing the Inbox folder.
    string s1 = rootStoreID.Substring(1, 75);
    string s2 = fo.StoreID.Substring(1, 75);
    if (s1 != s2)
    {           
        // unload the folder
        olMAPI.RemoveStore(fo);
    }    
}
olApp.Quit();

【问题讨论】:

    标签: c# outlook office-interop


    【解决方案1】:

    是的,您可以从其他应用程序自动执行 Outlook。 NameSpace 对象上有一个Logon 方法,因此您可以登录到配置文件,然后您可以做任何您想做的事情。但是我认为它会在自动化时再次弹出提示,但是..还有一个第三个库可以帮助您执行此操作,因为它通过 mapi 执行此操作。在redemption libray 中签出 profman.dll

    【讨论】:

      猜你喜欢
      • 2013-02-05
      • 1970-01-01
      • 2011-05-16
      • 1970-01-01
      • 1970-01-01
      • 2015-11-15
      • 2011-02-06
      • 2014-05-10
      • 1970-01-01
      相关资源
      最近更新 更多