Select current Outlook pst file
Posted on 2008-11-09
I have a script that finds what pst files are currently being used in Outlook and for now echos the file and path out.
Set objOutlook = CreateObject("Outlook.Application")
Set objNS = objOutlook.GetNamespace("MAPI")
For Each objFolder In objNS.Folders
If objFolder.Name <> "Mailbox" Then
For i = 1 To Len(input) Step 2
strSubString = Mid(input,i,2)
If Not strSubString = "00" Then
strPath = strPath & ChrW("&H" & strSubString)
Select Case True
Case InStr(strPath,":\") > 0
GetPSTPath = Mid(strPath,InStr(strPath,":\")-1)
Case InStr(strPath,"\\") > 0
GetPSTPath = Mid(strPath,InStr(strPath,"\\"))
Example: If I have 3 pst files open right now in Outlook I will get 3 message boxes such as
What I want to do is to create a case for the files found (in this case the 3 files found)
Then have a message box that I can list the 3 files found and select the one I want which will then store
that file path in a varible. So If I was to slect "D:\outlook\files\2008.pst" then in my script I could use
OutLookfile = "D:\outlook\files\2008.pst"
One other issue I have is this line ''''If objFolder.Name <> "Mailbox" Then
not a big deal but the Outlook .ost file is always named like "Mailbox - John Doe"
I do not want it to read this one, I've tried using a wildcare here but that cannot be done.
How can I match any name other than "Mailbox - some name"
Thanks for any help on this.