none
Outlook and Digital Guardian (Verdasys) RRS feed

  • Question

  • I observed a problem with an Outlook addin written in python after the installation of the Digital Guardian Security Suite. It seem like some of the mapi API has been changed. The following code snippet ran well before the installation of DG and fails now when calling IMAPISession.Logoff

    from win32com.mapi import mapi
    
    mapi.MAPIInitialize((0,mapi.MAPI_MULTITHREAD_NOTIFICATIONS))
    logonFlags = (mapi.MAPI_NO_MAIL |
                  mapi.MAPI_EXTENDED |
                  mapi.MAPI_USE_DEFAULT )
    session = mapi.MAPILogonEx(0, None, None, logonFlags)
    
    session.Logoff(0, 0, 0)
    session = None
    mapi.MAPIUninitialize()

    The error message is 'wrong parameter', windows error code -2147024809

    Since Logoff is the only method that fails I can live with not calling it but I would guess that this could lead to memory leaks

    Any ideas?

    Christian

    Friday, May 3, 2013 6:17 PM

Answers

  • You can retrieve it from the Outlook Object Model -

    Namespace.MAPIOBJECT returns IMAPISession.

    MailItem.MAPIOBJECT returns IMessage,

    MAPIFolder.MAPIOBJECT returns IMAPIFolder.

    Attachment.MAPIOBJECT returns IAttach.

    AddressEntry.MAPIOBJECT returns IMailUser

    Store.MAPIOBJECT returns IMsgStore.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, May 6, 2013 10:28 PM
  • Yes, that IMAPISession object can be shared between threads as long as each thread called MAPIInitialize.

    Keep in mind that in Outlook 2013, using *any* OOM object on a secondary thread will immediately raise an exception, even if that worked in the previous versions of Outlook.

    IMAPISession, being an Extended MAPI interface, is not a subject to that limitation.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by takutsirk Tuesday, May 14, 2013 12:47 PM
    Monday, May 13, 2013 11:39 PM

All replies

  • if this is an Outlook add-in, why are you initializing mapi subsystem by yourself? Outlook handles that for you. In broader sense - what are you trying to achieve? Maybe standard OOM is sufficient for that?
    Monday, May 6, 2013 6:39 AM
  • I need the extended mapi access. Anyway, the script fails if run standalone, too.
    Monday, May 6, 2013 3:53 PM
  • Christian,

    I see that you are having difficulties with the Verdasys Digital Guardian product. We at Verdasys would like to assist with this. If you could have one of your Digital Guardian administrators that has access to the Verdasys Support Portal open a support ticket and reference this thread we would be happy to assist in troubleshooting the problem that you are having with the Outlook Plugin. A support ticket can be opened by accessing the support portal at http://support.verdasys.com. We look forward to hearing from you.

    Thanks,

    Chris Loiselle

    Director, Global Technical Support

    Verdasys, Inc.

    Monday, May 6, 2013 4:59 PM
  • Why are you creating a new session in an Outlook add-in? Use IMAPISession from Namespace.MAPUIOBJECT.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, May 6, 2013 6:37 PM
  • Chris,

    my customer got in contact with you shortly after I posted here. Is problem is being locked at currently.

    Thank you, Christian

    Monday, May 6, 2013 9:06 PM
  • Thanks for pointing this out. I gave it a try but I did not succeed. In seems that the MAPIOBJECT does not have any properties/methods (using the python wrapper). I will investigate that later.

    Christian

    Monday, May 6, 2013 9:16 PM
  • Of course, because is not derived from IDispatch. You need to cast it to IMAPISession - that is what your session variable is, right?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, May 6, 2013 9:18 PM
  • Apologies for my ignorance, but where do I get an IMAPISession object if not by calling IMAPIInitialize and Logon?

    Christian

    Monday, May 6, 2013 10:16 PM
  • You can retrieve it from the Outlook Object Model -

    Namespace.MAPIOBJECT returns IMAPISession.

    MailItem.MAPIOBJECT returns IMessage,

    MAPIFolder.MAPIOBJECT returns IMAPIFolder.

    Attachment.MAPIOBJECT returns IAttach.

    AddressEntry.MAPIOBJECT returns IMailUser

    Store.MAPIOBJECT returns IMsgStore.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, May 6, 2013 10:28 PM
  • You can retrieve it from the Outlook Object Model -

    Namespace.MAPIOBJECT returns IMAPISession.


    I got it. For the records, in python it can be achieved like this:

    outlook.GetNamespace('MAPI').Session.MAPIOBJECT.QueryInterface(mapi.IID_IMAPISession)
    Since with this approach it is no longer necessary to call Logoff, the original problem is solved.

    Thank you all, Christian



    • Edited by takutsirk Wednesday, May 8, 2013 4:34 PM
    Wednesday, May 8, 2013 4:30 PM
  • One more question: how about threading? Can I use that session (borrowed from outlook) from all threads after calling MAPIInitialize?

    Regards, Christian

    Monday, May 13, 2013 11:26 PM
  • Yes, that IMAPISession object can be shared between threads as long as each thread called MAPIInitialize.

    Keep in mind that in Outlook 2013, using *any* OOM object on a secondary thread will immediately raise an exception, even if that worked in the previous versions of Outlook.

    IMAPISession, being an Extended MAPI interface, is not a subject to that limitation.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by takutsirk Tuesday, May 14, 2013 12:47 PM
    Monday, May 13, 2013 11:39 PM
  • Thanks for pointing that out.

    Christian

    Tuesday, May 14, 2013 12:39 PM