Reading mails from Outlook

Discussion in 'Python' started by beeswax, Feb 22, 2007.

  1. beeswax

    beeswax Guest

    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
    beeswax, Feb 22, 2007
    #1
    1. Advertising

  2. beeswax

    Larry Bates Guest

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

    -Larry
    Larry Bates, Feb 22, 2007
    #2
    1. Advertising

  3. beeswax

    beeswax Guest

    On 22 feb, 15:45, Larry Bates <> wrote:
    > 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/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
    beeswax, Feb 23, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jamal

    reading e-mails

    jamal, Aug 1, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    463
    Marcel
    Aug 1, 2005
  2. Replies:
    0
    Views:
    343
  3. JLC
    Replies:
    2
    Views:
    3,604
    winbatch
    Nov 24, 2003
  4. KellyLynch
    Replies:
    1
    Views:
    527
    red floyd
    Jan 20, 2010
Loading...

Share This Page