none
How to make copy of Inline Response mailItem object? RRS feed

  • Question

  • Hello guys.

    To parse Outlook mail item I've used Redemption library. So, for getting recipients (CC/BCC/To) correctly I need to previously save this mail item.

    However, I can't just call mailItem.Save(), because some plugins will work incorrectly. To resolve this problem, I've added custom logic, which creates duplicate of mailItem (mailItem.Copy()) and works with it.

    Could you please, let me know, if there is any ways to create copy of Inline Reply mail item? As I know, mailItem.Copy() method isn't supported.


    Friday, October 18, 2013 8:56 AM

Answers

  • When you change an item or add recipients to it, or modify it in any way Outlook will modify a cached copy of the item that's kept in memory. The changes aren't committed to the actual item until it's saved. So until the item is saved MAPI won't know about the changes, and therefore Redemption won't know about the changes.

    I don't know that you're going to be able to do what you want with the inline responses. About the only thing I can suggest is to live with saving the items first. I don't know that a support incident would help in trying to get a hot fix to change the behavior, I don't think that's going to be an option.


    Ken Slovak MVP - Outlook

    Monday, October 21, 2013 2:18 PM

All replies

  • The inline reply item can be gotten from using ActiveExplorer().Selection[1]. That object can be cast as a MailItem.

    Ken Slovak MVP - Outlook

    Friday, October 18, 2013 2:28 PM
  • The inline reply item can be gotten from using ActiveExplorer().Selection[1]. That object can be cast as a MailItem.

    Ken Slovak MVP - Outlook

    Thank you for you reply!

    Yes, there is no problem for me to get original mailItem object, which represents inline Response. The main problem I encountered is that I need to get copy of this COM object (For some reasons, I can't work with original item). For Inspector item I able to call Copy() method and get duplicate. But, as my investigation shows, I can't implement this approach for inline response.

    Is there any ways to get copy of Inline response Item? It is very important to do it.

    Friday, October 18, 2013 3:00 PM
  • If you get the mail item as I mentioned you should be able to use its GetInspector() method to get an Inspector object for it and then make a copy from that. See if that works for you.

    Ken Slovak MVP - Outlook

    Friday, October 18, 2013 5:36 PM
  • I've tried to run the next code:

    MailItem item = (MailItem)(((MailItem)item).GetInspector.CurrentItem);

    where item - object of InilineResponse event. As I know, this object represents iniline response mail item.

    When this code runs, my Outlook application hangs out.

    Also, I've tried instead item object use ActiveExplorer().Selection[1] object, as you suggested,

    Maybe I do something wrong?

    Friday, October 18, 2013 6:18 PM
  • No, I don't think you're doing anything wrong. It's just not working.

    There are limitations that are on inline responses as a matter of policy, there are others that are just bugs. I have 2 bugs on inline responses open myself, I know of a number of others. The latest Outlook 2013 hotfix that came out this week has at least one inline response bug fix, for trying to attach files to an open inline response and having the body revert to the original text.

    You might just have to save the item even if it causes conflicts with other code.

    Are you able to open a support incident with MS support on this?

    If you can, you can get the question of whether it's a bug or not determined, and you might be able to get a hot fix if it is a bug.


    Ken Slovak MVP - Outlook

    Friday, October 18, 2013 6:36 PM
  • Ok, thank you!

    I don't think, that in my case I have bug in MS Outlook. I have to create copy of mail item, because some Outlook plugins bind to "Save" event and do some changes in application behavior. Thereby, as Outlook user, if I don't explicitly click "Save" button,  I don't expect, that some strange things will happen.

    Another way to get recipients (getting recipients - is my initial target) - get mailInfo.Recipients properties (to do it, i haven't to save mail item). But as I know, Outlook security dialog might be displayed in this way (is there any ways to prevent it?). As my investigation shows, no dialog will appeared if antivirus software enabled on users PC (if I'm wrong, please let me know).

    I think, you understand me.

    Friday, October 18, 2013 7:26 PM
  • If the code is running in a VSTO addin, and you derive all your Outlook objects from the trusted Application object available from this.Application in the startup handler you shouldn't trigger the security.

    That's if A-V is current and the other security settings aren't restricted in some way.

    However, if you're using Redemption code you shouldn't trigger the security at all. That's the original reason Redemption was created and specified.

    What are you using, an RDOMail item or a SafeMailItem?


    Ken Slovak MVP - Outlook

    Friday, October 18, 2013 7:53 PM
  • I develop custom window application, which attaches to Outlook process and capture users activities (reading/writing emails, appointments). It's not a VSTO addin and I don't think, that it's security safely.

    Earlier (before Outlook 2013 version realised) I've been able to use Redemtion with SafeMailItem. The main problem, that for correctly getting recipients (To/CC) the mail item object should be saved (I really don't know, why it should be done). As I said in previous comments, I just create copy of mailitem object, save it, parse via Redemption and delete. This process works correctly for all cases.

    But for inline response item I can't do it in the same way.

    I have ability to work with mail item of Outlook object model (which not security safely) and with Redemtion SafeMailItem (I need previously save email).

    Saturday, October 19, 2013 6:18 AM
  • When you change an item or add recipients to it, or modify it in any way Outlook will modify a cached copy of the item that's kept in memory. The changes aren't committed to the actual item until it's saved. So until the item is saved MAPI won't know about the changes, and therefore Redemption won't know about the changes.

    I don't know that you're going to be able to do what you want with the inline responses. About the only thing I can suggest is to live with saving the items first. I don't know that a support incident would help in trying to get a hot fix to change the behavior, I don't think that's going to be an option.


    Ken Slovak MVP - Outlook

    Monday, October 21, 2013 2:18 PM
  • Ok, thank you very much!

    I didn't find any solution how to make copy of inline response, and decided to save original mail item (chosen the lesser of two evils).

    Monday, October 21, 2013 2:30 PM