Fun with Outlook and MAPI

Steve Holden steve at holdenweb.com
Mon Dec 13 15:28:58 EST 2004


Chris wrote:

>> There is actually a workaround. You're using Simple MAPI which has a 
>> nice easy interface. The confirmation dialogs are only for Simple 
>> MAPI. Using Extended MAPI can work around the problem but its a lot 
>> more tricky.
>> See the initial discussion here: 
>> http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2160646
>>
>> This code has now been included in pywin32 somehow but I can't 
>> remember where and its late. Should also be a cookbook entry. Maybe 
>> Google can help :-)
> 
> 
> Okay, here's the results.  The good news is that the code sent the mail 
> without any popup's.  The bad news is that the sent e-mail stays in the 
> outbox instead of the sent folder.  Any suggestions?
> 
> Chris

Well, only the same one I've already made, which is to look on the 
win32all mailing list archives. Since this appears to be beyond you, 
here's a note by Chad Stryker commenting on an original work by David 
Fraser.

It may give you the clues you need, otherwise Google for the whole 
thread(s).

"""Thank you for figuring this extended MAPI interface all out.  I 
discovered a couple of problems with the code (on my system at least). 
First, the message in my outbox was marked as read.  Second, the message 
would remain in the outbox after it was sent.  After several hours of 
work, I added three lines to the function that mark the message as 
unread and cause the message to be deleted from the outbox after it is sent.

First, I added a constant that I found in the MAPI header file MAPIDefS.h.

CLEAR_READ_FLAG = 4

Next I added two lines just before “outboxfolder.SaveChanges(0)”.

message.SetReadFlag(CLEAR_READ_FLAG)
message.SetProps([(mapitags.PR_DELETE_AFTER_SUBMIT,1)])

With these changes, the behavior in the outbox is consistent with 
sending messages directly from Outlook.
"""

regards
  Steve
-- 
Steve Holden               http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC      +1 703 861 4237  +1 800 494 3119



More information about the Python-list mailing list