, , win32com , ... , -, -, , , MSDN
python script, Outlook, , .
, , , .
import win32com
import win32com.client
import string
import os
def findFolder(folderName,searchIn):
try:
lowerAccount = searchIn.Folders
for x in lowerAccount:
if x.Name == folderName:
print 'found it %s'%x.Name
objective = x
return objective
return None
except Exception as error:
print "Looks like we had an issue accessing the searchIn object"
print (error)
return None
def main():
outlook=win32com.client.Dispatch("Outlook.Application")
ons = outlook.GetNamespace("MAPI")
one = '<your account name here>@<your domain>.com'
Folder1 = findFolder(one,ons)
Folder2 = findFolder('Inbox',Folder1)
Folder3 = findFolder(<your inbox subfolder>,Folder2)
messages = Folder3.Items
for xx in messages:
try:
print xx.Subject,xx.Sender,xx.Body
xx.Move(Folder3)
except Exception as err:
print "Error accessing mailItem"
print err
if __name__ == "__main__":
main()
PS , , .