그래, C# 응용 프로그램에서 Outlook Interop 어셈블리를 사용하여 .PST 파일을 식별하는 데 문제가 없습니다. 그러나 암호로 보호 된 파일을 누르 자마자 암호를 묻는 메시지가 나타납니다. 조직에서 PST를 사용하지 않도록 설정하는 중입니다. 단계 중 하나는 사용자의 Outlook 프로필에서 PST 파일을 언로드하는 것입니다. 이 앱을 자동으로 실행하고 사용자에게 메시지를 표시하지 않아야합니다. 어떤 아이디어? UI가없는 Outlook.Application 개체를 만든 다음 암호로 보호 된 파일에 Exception을 catch하려고 시도 할 수 있습니까?Outlook Interop : 암호로 보호 된 PST 파일의 두통
// 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();