Is there any Library for Python (Windows) to read the Internal Directory structure of PST file eg. Inbox, Drafts, etc including Folders created by Users.
1 Answers
as per https://support.microsoft.com/en-us/kb/287070
Microsoft Outlook automatically stores messages, contacts, appointments, tasks, notes, and journal entries in one of the following two locations: In a personal storage folder, also known as a .pst file, on your hard disk drive. In a mailbox that is located on the server. Your mailbox is located on a server if you use Outlook with Microsoft Exchange Server.
so, based on this info, you should be able to use OS
import os
documentation for the library is here: https://docs.python.org/3/library/os.html
The following example shows a simple use of scandir() to display all the files (excluding directories) in the given path that don’t start with '.'. The entry.is_file() call will generally not make an additional system call:
for entry in os.scandir(path):
if not entry.name.startswith('.') and entry.is_file():
print(entry.name)
for validating directories: using listdir(path) lists available directories within the specified path, adding further logic, you should be able to achieve what you want Ex:
import os
cdirs = os.listdir("C:/")
print(cdirs)
or create a function to do this:
def file_check(path):
file_dirs = listdir(path)
#do something with this
return file_dirs

- 2,325
- 1
- 22
- 39
-
I am not talking about pst file location, The question is basically related to the PST file's structure. PST contains the attributes which are mentioned by you. I want to fetch the internal folder names from the pst file. – jaymin581 May 20 '16 at 04:05
-
using listdir(path) and some logic, you should be able to "scan" for directories. – glls May 20 '16 at 04:07
-
Dear @glls, As per my knowledge, listdir only applicable to folders not files. pst considered by OS as a file. – jaymin581 May 20 '16 at 04:13
-
i did not know that, could you include it in your orig. question? in that case, you would have to use scandir and maybe open the pst files. (dont know what this would result in) but are you able to read the pst file using python or tried? and based on the content categorize ? – glls May 20 '16 at 04:15
-
http://stackoverflow.com/questions/3197388/outlook-pst-file-parsing-in-python ? (question was closed as marked OFF TOPIC) – glls May 20 '16 at 04:19