MAPI support for PR_REPLY_RECIPIENT_ENTRIES
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
I was able to replace most of my existing C++ based sendmail.exe program with a Python script using pythoncom.mapi.
Great work!
However, I am not able to specify a different Reply-To address, because the mapi package does not support the FLATENTRY and FLATENTRYLIST structures.
Note: Working C++ code for specifying a different Reply-To address can be found at http://support.microsoft.com/kb/300531
OK, as a workaround it is possible to modify the reply-to address with a bit low-level code (see below). So, my problem is solved. Anyway, perhaps this could be a nice addition to the mapiutil package.
code fragment to set the replyTo-Address
def makeentry(typ, name_addr):
return ((mapitags.PR_RECIPIENT_TYPE, typ),
#(mapitags.PR_DISPLAY_NAME_A, name_addr),
(mapitags.PR_DISPLAY_NAME_W, name_addr),
)
# ReplyTo-Address
if replyTo:
# replyTo is a unicode string
replyToList = address_book.ResolveName(0, mapi.MAPI_UNICODE, None, [makeentry(mapi.MAPI_TO, replyTo)])
props = [(mapitags.PR_REPLY_RECIPIENT_NAMES, replyTo),
]
message.SetProps(props)
replyToAddr = replyToList[0]
for (pt, pv) in replyToAddr:
if pt == mapitags.PR_ENTRYID:
entryid = pv
break
#print "reply-to entryid (len %s): %r" % (len(entryid), entryid)
flatentry = struct.pack("i", len(entryid)) + entryid
#print "flatentry:", repr(flatentry)
flatentrylist = struct.pack("ii", 1, len(flatentry)) + flatentry
props = [
(mapitags.PR_REPLY_RECIPIENT_ENTRIES, flatentrylist),
]
message.SetProps(props)
A complete, working example