2

Is there a way to check if a microsoft outlook pst file is password protected or not using c#. I'm trying to read the pst file using the below code.

Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace outlookNs = app.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.MAPIFolder emailFolder = outlookNs.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
pnuts
  • 58,317
  • 11
  • 87
  • 139
agasthyan
  • 725
  • 3
  • 8
  • 17
  • 1
    http://stackoverflow.com/questions/15124834/check-if-a-pst-file-is-password-protected-with-java-libpst –  Mar 08 '13 at 06:14

1 Answers1

1

I don't know if there is a property in the api, as a work around you could query the contacts or email folder. If the pst file is protected, it shouldn't work.

MAPIFolder contacts = olMAPI.GetDefaultFolder(OlDefaultFolders.olFolderContacts)

foreach (ContactItem contact in fcontacts .Items)
{
   ...
}
Kai
  • 1,953
  • 2
  • 13
  • 18
  • well if its password protected it will prompt for password.I just want to know if its password protected in order to avoid that password prompt – agasthyan Feb 20 '13 at 14:12