PST Processing Using Ruby

I am going to write code to extract information about the contents of PST files, such as general messages, a list of subfolders, the number of messages in a folder, the name of the email subject and the date of sending / receiving for each message.

This is a work in progress, and I should familiarize myself with Ruby / Outlook / MAPI when I go.

I work on Windows with the following code snippet to understand how I can access the contents of the PST:

#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 can add the pst file via the file name to delete it, I need to know what name was assigned to the file in Outlook. This is normal. If I am configured manually, but I want it to run autonomously.

Is there a way that I can extract and assign pst 'name' to a variable after loading to get around this problem or is there another way to upload pst file (s) that I don't know about?

+3
source share
1 answer

Try using array methods

outlook.Session.AddStore('C:/test.pst')
mapi.RemoveStore(mapi.Folders.Item.last)

Another option is to iterate through mapi.Folders before you add it. Then try again and find the new name "Item" that is displayed, then delete it.

0
source

All Articles