-
Notifications
You must be signed in to change notification settings - Fork 25
/
testmapiex.py
38 lines (27 loc) · 1.08 KB
/
testmapiex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import mapiex
# Change these to something valid before running !!!!
eml = 'PATH TO EML FILE'
storename = 'VALID MAPI STORE NAME'
dirname = 'VALID MAPI DIRECTORY NAME TO CREATE IN STORE'
# Test of enumeration of the message stores that are opened
def EnumerateMessageStore (MAPI) :
for name in MAPI.GetMessageStoreNames() :
print("Store Name : %s" % name)
# Enumeration of the subfolders of a messagestore
def EnumerateSubFolders (folder, indent="") :
f = folder.GetFirstSubFolder ()
while f != None :
print("%sSubFolder : %s" % (indent, f.name))
EnumerateSubFolders (f, indent + " ")
f = folder.GetNextSubFolder ()
MAPI = mapiex.mapi()
print("Profile Name : %s " % MAPI.GetProfileName())
print ("Profile Email : %s" % MAPI.GetProfileEmail())
EnumerateMessageStore (MAPI)
MAPI.OpenMessageStore (storename)
rootfolder = MAPI.OpenRootFolder ()
EnumerateSubFolders (rootfolder)
folder = rootfolder.CreateSubFolder (dirname)
if folder == None :
print("Can't open folder %s" % dirname)
folder.ImportEML (eml)