none
Is there a different for attachment inside an email when Use Cached Exchange Mode is enabled or disabled? RRS feed

  • Question

  • I have an outlook add-in that could save an email into a Document system, when Use Cached Exchange Mode is enabled, we could check the email for attachment and then save the email and its attachment OK, BUT if Use Cached Exchange Mode is disabled, we could detect the email, then it seems there is an error in the process of checking the attachment? Because we got the error popup "Cannot move the items. The item cannot be moved. It was either already moved or deleted, or access was denied". I try to debug into our code, but only see Outlook's dll in the call stack so not sure how could I debug further to figure why?

    I also posted this question in TechNet forum.

    Any feedback or help would be greatly appreciated.

    Regards,


    Tuesday, June 11, 2019 1:46 PM

All replies

  • Please post the relevant snippet of your code and indicate which line raises the exception.

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

    Tuesday, June 11, 2019 3:07 PM
  • We implement for a "Drag and Drop" an email from Inbox to a node in Document Management, it uses MAPI, i.e IMessage and IAttach interface, which is in C++. I could not figure it out where the exception occurs! 

    The pseudo code are:

     (1) Outlook calls CMAPIFolder::CreateMessage(LPCIID lpInterface, ULONG ulFlags, LPMESSAGE* lppMessage)

          to create a message in the destination folder. Message store creates an   instance of message in the destination folder, and return to Outlook. 

          In this function, a CDOCSMessage is created, which implements IMessage       interface.

     (2) With the return reference to the message, Outlook will further construct   the message such as set certain properties and add attachments etc. by these sequences:

    a) //Outlook call our message to create attachment
    CDOCSMessage::CreateAttach(LPCIID lpInterface, ULONG ulFlags, ULONG* lpulAttachmentNum, LPATTACH* lppAttach)
    b) // Then set property to the attachment
    STDMETHODIMP CAttach::SetProps(BOOKMARK cValues, LPSPropValue lpPropArray, LPSPropProblemArray* lppProblems)

    c)// Somehow polulate the data in the message by outlook
    STDMETHODIMP CAttach::GetProps(LPSPropTagArray lpPropTagArray, BOOKMARK ulFlags, ULONG* lpcValues, LPSPropValue* lppPropArray)

    In the case that works (Use Cached Exchange Mode is enabled), I could see the sequences are called, BUT for the fail case, I saw just the call to CDOCSMessage::CreateAttach(LPCIID lpInterface, ULONG ulFlags, ULONG* lpulAttachmentNum, LPATTACH* lppAttach)

    Then I see the error from Outlook.



    Tuesday, June 11, 2019 5:57 PM
  • I just found out that after Outlook call our message to create attachment
    STDMETHODIMP CDOCSMessage::CreateAttach(LPCIID lpInterface, ULONG ulFlags, ULONG* lpulAttachmentNum, LPATTACH* lppAttach)

    It calls into our method

    STDMETHODIMP CAttach::GetIDsFromNames(ULONG cPropNames, LPMAPINAMEID* lppPropNames, ULONG ulFlags, LPSPropTagArray* lppPropTags)

    in which we just return MAPI_E_NO_SUPPORT indicates that our message store does not support this capability, and it still works OK in the case of "Use Cached Exchange Mode" is enabled, BUT if it is off then I have the error. It looks like that Outlook has changed its requirements for some reason to require all message store to have the capability when cache mode disabled

    If I just return S_OK when "Use Cached Exchange Mode" is disabled then it works OK?
    So now I need to check if "Use Cached Exchange Mode" is enabled, I have to return MAPI_E_NO_SUPPORT as before; else I have to return S_OK for it to work properly. It is a little of "hacking". Not sure if there is anything I could do to make it more elegant?

    Regards,


    Phong Nguyen

    Wednesday, July 3, 2019 5:53 PM
  • So you don't support named properties on attachments? Or on any objects (including messages) in your store?

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

    Wednesday, July 3, 2019 6:02 PM
  • Yes, we do support named properties for MAPIFolder and Message, but NOT attachment, it seems to work with previous version of Outlook. The weird thing is that if I just return S_OK in the case "Use Cached Exchange Mode" is disabled, it works OK. I am not familiar with these named properties so it is hard to "digest" :-)

    Phong Nguyen

    Wednesday, July 3, 2019 8:58 PM
  • All of your store objects should support the same set of mappings on all its objects - it should not matter whether the code calls GetIDsFromNames on IMsgStore, IMAPIFolder, IMessage, or IAttach.

    For example, I can call GetIDsFromNames on IMAPIFolder to figure out property tags set on messages when I build a search - there is simply no IMessage to call GetIDsFromNames on. Exchange provider would let me do that even though it does not support named properties on folders. That only matters when properties are set.


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



    Wednesday, July 3, 2019 9:32 PM
  • Thanks for your reply.

    Our code have method GetIDsFromNames() implemented for IMsgStore, IMAPIFolder, (for IMessage, we just call IMAPIFolder's method to handle it). At the moment we don't implement the method IAttach, I just see that Outllook calls this method after IMessage::CreateAttach() is called, so not sure what Outlook needs from this IAttach::GetIDsFromNames(), that's why I don't know what it needs in this method, so I could implement it.

    Regards


    Phong Nguyen

    Friday, July 5, 2019 2:06 PM