[python-win32] extended MAPI error: outbox folder?

stephen emslie stephenemslie at gmail.com
Mon Sep 13 14:03:08 CEST 2004


I short while ago David Frasure and I wrote a short piece of code for
sending email using extended MAPI and posted it to this list. However,
it seems that it doesn't work 100% of the time. Perhaps you can help
me figure out why...

I get the following error:
    outboxfolder = msgstore.OpenEntry(eid,None,mapi.MAPI_BEST_ACCESS)
TypeError: EntryID must be a string or None

I think this basically means that it cant open the outbox (which needs
to be done to create a new message in it). Below I've shown how the
outbox is currently opened up till the point of the error. I'm almost
sure that there must be a better way to gain access to the outbox
folder. Does anyone know of a reliable method?

The strange thing is that our code works perfectly on most systems. I
am not sure why it works on some systems but not others.

I got the current method of opening the outbox from an article on the
code project (http://www.codeproject.com/internet/mapadmin.asp),
specifically the createmessage function.

here is the my code snippit up to the line that generates the error:

    # initialize and log on
    mapi.MAPIInitialize(None)
    session = mapi.MAPILogonEx(0, MAPIProfile, None,
mapi.MAPI_EXTENDED | mapi.MAPI_USE_DEFAULT)
    adminprofiles = mapi.MAPIAdminProfiles(0)
    messagestorestable = session.GetMsgStoresTable(0)
    statustable = session.GetStatusTable(0)
    messagestorestable.SetColumns((mapitags.PR_ENTRYID,
mapitags.PR_DISPLAY_NAME_A, mapitags.PR_DEFAULT_STORE),0)

    while (True):
        rows = messagestorestable.QueryRows(1, 0)
        if len(rows) != 1:
            break
        row = rows[0]
        property,value = row[0]
        if (property == mapitags.PR_DEFAULT_STORE and value == True):
            break

    # unpack the row and open the message store
    (eid_tag, eid), (name_tag, name), (def_store_tag, def_store) = row
    msgstore = session.OpenMsgStore(0,eid,None,mapi.MDB_NO_DIALOG |
mapi.MAPI_BEST_ACCESS)

    # get the outbox
    hr, props = msgstore.GetProps((mapitags.PR_IPM_OUTBOX_ENTRYID), 0)
    (tag, eid) = props[0]
    outboxfolder = msgstore.OpenEntry(eid,None,mapi.MAPI_BEST_ACCESS)

<this is where the error is encountered>

Thanks for any help
Stephen Emslie


More information about the Python-win32 mailing list