Reading mails from Outlook

B

beeswax

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
 
L

Larry Bates

beeswax said:
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/showfiles.php?group_id=61702&package_id=58141

-Larry
 
B

beeswax

>

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top