I am in the process of writing some code to extract information about the contents of PST files such as the total messages, sub folder listing, number of messages per folder, email subject name and sent/received date for each message.
It is a work in progress and I am having to familiarise myself with Ruby/Outlook/MAPI as I go along.
I am working in windows with the following code snippet to gain an understanding of how I can access PST content:
#Create outlook instance
outlook = WIN32OLE.new('Outlook.Application')
#Create mapi control
mapi = outlook.GetNameSpace('MAPI')
outlook.Session.AddStore('C:/test.pst')
#pst = mapi.Folders.Item('Personal Folders')
#puts pst.Items.count
#mapi.RemoveStore(pst)
Although I am able to add a pst file via the file name, in order to remove it I need to know what the name assigned to the file in outlook is. This is fine If I am manually in outlook but I wish this to run autonomously.
Is there a way I can extract and assign the pst 'name' to a variable after loading in order to get around this issue or is there another way to unload the pst file(s) I am unaware of?