>
I'll bet that some of the best information you can get about interacting
with Outlook is going to be by looking at the sourcecode to SpamBayes
plug-in. You can get it from here:
https://sourceforge.net/project/showfiles.php?group_id=61702&package_...
-Larry
Hi again,
I found the solution myself, the next code will iterate all folders,
sub folders and their mails.
I just needed to understand what I could do with the folders objects.
But, this code will trow an error when trying to connect to shared
folders (exchange folders etc).
Btw does anyone knows a good API for this, or a way to get all the
properties from an object?
# Create instance of Outlook
o = win32com.client.gencache.EnsureDispatch("Outlook.Application")
# Dump all folders recursive, starting from root
DumpFoldersRecursive(o.GetNamespace("MAPI").Folders,0)
o = None
def DumpFoldersRecursive(folders,indent):
# Note: the com indexes start from 1
for i in range(1,folders.Count+1):
folder = folders
print '%sFolder %d: "%s"' %
('\t'*indent,i,DecodeUnicodeString(folder.Name))
# if a folder has no subfolders, its Folders.Count will be
zero, so this is safe.
for i in range(len(folder.Items)):
message = folder.Items[i+1]
print message.Subject
DumpFoldersRecursive(folder.Folders,indent+1)
Regards,
Sam