Python and MS Exchange

Mark Hammond mhammond at skippinet.com.au
Thu Feb 12 17:01:32 EST 2004


Lindstrom Greg - glinds wrote:

> I'm using python 2.3 and Windows 2000 "Professional" to access a Microsoft
> Exchange Server to monitor messages and perform various tasks around the
> office.  My little program is attracted quite a bit of attention and I have
> been asked to add some features, but I don't know how to do a couple of
> things.  Can anyone either help me out with the details, or point me to
> where I can get the information?  Here's my task list:
> 
> 1.  Create a folder for the mailbox.  For example, I would like to have a
> "Processed" folder where I can move messages once they have been processed.
> 
> 2.  How can I check to see if a folder exists?
> 
> 3.  Can I access the allotted size of a folder to determine if I have room
> to post messages?
> 
> 4.  How do I move a message to the folder I just created?
> 
Can you tell us what object model you are using?  Provide a little 
sample code to give us a clue.

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