Python and MS Exchange

Greg Lindstrom yuba at cyberback.com
Fri Feb 13 11:18:26 EST 2004


> Can you tell us what object model you are using?  Provide a little 
> sample code to give us a clue.

Sure thing.

from win32all.client import Dispatch

mailbox = Dispatch("MAPI.session")
mailbox.Login(profile='MS Exchange Settings')

# Now *I* think I should be able to do the following
mailbox.listfolders()

# but I get...
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python23\lib\site-packages\win32com\client\dynamic.py",
line 460, in __getattr__
    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: MAPI.Session.listfolders

# so, I've already taken a wrong turn!


I've got the SpamBayes source code (BTW- I've been using SpamBayes for
about 6 months and love it...very little SPAM gets through to me
anymore) and will be looking it over this weekend.

Is there a way to examine the mailbox object above to see what methods
are available?

Thanks for your help.  I am keeping notes and plan to write up a
summary for others.

--greg


> 
> 1) If you are yusing MAPI, there is a CreateFolder method.
> 2) Try to open it, and if it fails, check the error code.
> 3) This is probably in a property on the folder.  Check the Exchange 
> forums for what folder property you need.
> 4) A "Move" method.
> 
> Check out the SpamBayes project, and look at the source code to the 
> Outlook Addin - in general, this uses MAPI (which is basically the 
> 'exchange object model'), but also does a few things via the Outlook 
> object model - so you get a few examples of both.  MAPI has a bigger 
> learning curve, but is more powerful and faster.
> 
> Mark



More information about the Python-list mailing list