On 22 feb, 15:45, Larry Bates <lba...@websafe .comwrote:
beeswax wrote:
Hi,
Does anyone knows how to read e-mails from a specific folders in
outlook?
I only found out how to read the mails from the inbox folder and how
to list all available folder.
I just don't found a way to access my mails from the other folders.
Can anyone help me?
Regards,
Sam
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/show...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.Ensur eDispatch("Outl ook.Application ")
# Dump all folders recursive, starting from root
DumpFoldersRecu rsive(o.GetName space("MAPI").F olders,0)
o = None
def DumpFoldersRecu rsive(folders,i ndent):
# Note: the com indexes start from 1
for i in range(1,folders .Count+1):
folder = folders[i]
print '%sFolder %d: "%s"' %
('\t'*indent,i, DecodeUnicodeSt ring(folder.Nam e))
# if a folder has no subfolders, its Folders.Count will be
zero, so this is safe.
for i in range(len(folde r.Items)):
message = folder.Items[i+1]
print message.Subject
DumpFoldersRecu rsive(folder.Fo lders,indent+1)
Regards,
Sam