none
Moving Encrypted Messages Issue Outlook 2007 VSTO Addin RRS feed

  • Question

  • Hello,

    I previously posted this issue and was able to get enough help that I could atleast filter these messages out and not move them.

    Here is link to the previous post: http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/a4c8fc8d-9d16-4d24-95ec-15b6c562b734

    The exact issue is that I can move encrypted messages to a pst without issue, however when I go to return them to an exchange mailbox the (PR_MESSAGE_DELIVERY_TIME ) is changed to the exact moment when the message was moved back to exchange mailbox and not the actual time that it was originally received.

    I am hoping someone might be able to point me in a direction that will allow me to restore these messages to the exchange mailbox with the correct received date/time intact.

    Thursday, October 13, 2011 6:54 PM

All replies

  • Outlook Object Model always changes PR_MESSAGE_DELIVERY_TIME whenever it saves a mesage.

    Just to be sure, this is an Exchange mailbox, not an Exchabge Public Folder?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Thursday, October 13, 2011 8:24 PM
  • Nope, not Public Folder, and maybe I have stated something incorrectly.

    When looking at the messages after moving them to a pst they maintain the date received visible within the outlook interface. When moving messages back to the exchange mailbox from the pst all the encrypted messages get their date received value set to the moment they got placed back in the mailbox. If the message is not encrypted you don't have this issue it moves back and forth without issue.

    Hope that makes since.

    Thursday, October 13, 2011 8:43 PM
  • How do you move the messages?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Thursday, October 13, 2011 8:46 PM
  • Outlook.Items dItems = dFolder.Items

    for (int i = dItems.Count; i <= dItems.Count; i--)

    {

    if(dItems[i] is Outlook.MailItem)

    {

    Outlook.MailItem mi = dItems[i] as Outlook.MailItem;

    mi.move(DestFoler);

    }

     

    Thursday, October 13, 2011 8:56 PM
  • I don't think there is anything you can do using OOM alone - it always represents signed/encrypted messages as regular MailItem objects. I guess after a message is decrypted, Outlook does not use IMAPIFolder::CopyMessages() to move the messages.

    Is using Extended MAPI or Redemption an option?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Friday, October 14, 2011 3:47 AM
  • Dmitry,

    I could use Extended Mapi but I don't believe I would be able to use Redemption, I am sure using Redemption would make this much easier.

    I wouldn't know where to begin in using extended mapi, but I am sure I can figure some of it out on my own if pointed in the right direction. I am really new to programming for Outlook.

    Thanks for any help you can provide.

    Ed

    Friday, October 14, 2011 11:42 AM
  • Firstly, your code would need to be C++ or Delphi. C# does not support Extended MAPI. There used to be a product called MAPI33, but I do not think it is still available or supported.

    That being said, you would need to get a pointer to both source and target IMAPIFolder MAPI objects (you can retrieve them from OOM using MAPIFolder.MAPIOBJECT), then call IMAPIFolder::CopyMessages() on the source folder and pass a pointer to the list of entry ids from the source folder, pointer to the target folder, and MESSAGE_MOVE flag. 


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Friday, October 14, 2011 4:49 PM
  • Ok I will give this a shot this weekend. I have barely done any coding in C++ so wish me luck... :-) I hope it solves the problem as this would be well worth it if so. Thanks again,
    Friday, October 14, 2011 5:01 PM
  • Before you do that, it does work in your environment if you drag the messages manually from PST to Exchange, right?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Friday, October 14, 2011 5:04 PM
  • Yes it works fine if I move it in the Outlook interface or if I use MFCMAPI it works as well.
    Friday, October 14, 2011 5:05 PM
  • I have an update. By changing the addin to grab a handle to the Outlook application and not creating a new instance I am seeing a different behavior.

    I am now getting a message for the encrypted messages stating the following:

    Message Box Title = Microsoft Office Outlook

    Message Box Icon = Red X

    Message Box text = You have changed this message. If you save the changes, the message will no longer be digitally signed. Do you want to save your changes?

    If I click yes the message gets moved to the correct folder but the received date is incorrect as previously mentioned.

    If I click no the message gets moved to the correct folder with the correct date received.

    Note: The messages are digitally signed and encrypted not just signed.

    Armed with this new information and not having the chance to tackle the IMAPIFolder::CopyMessages code yet, does anyone have any ideas.

    Wednesday, October 26, 2011 6:08 PM
  • Do you get that when calling MailItem.Move?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Wednesday, October 26, 2011 6:23 PM
  • Yes

    Wednesday, October 26, 2011 7:59 PM
  • This kind of makes sense (at least in the OOM world) - the message gets moved, but then Outlook tries to update the received date (I have no idea why). And when it tries to save the message, it displays the warning.

    I think the workaround is still the same: Extended MAPI (C++ or Delphi) or Redemption.


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

    Wednesday, October 26, 2011 8:29 PM
  • I just made an interesting discovery. In getting an Outlook table for a folder, and adding a column to the columns collection for (MessageClassProp) to determine if the message is encrypted or not, I found that the ["EntryID"] field doesn't match of any of the Entry ID's for the mail items in the folder when using MailItem.EntryId.

    Has anyone else ran accross this?

    Thursday, October 27, 2011 8:02 PM
  • Sure. Most likely you are getting a short term entry id.

    If you want the long term entry id, you need to specify the PR_LONGTERM_ENTRYID_FROM_TABLE expliclty (DASL name is http://schemas.microsoft.com/mapi/proptag/0x66700102).

    This property is Exchange specific.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!
    Thursday, October 27, 2011 8:21 PM
  • I noticed that as well, just before your reply. However the return I am getting from that call is a Byte[] so I am having to use a bitconverter to move that to string and then I am going to have to loop through that and remove he "-" between each.

    Thanks again Dmitry

    Thursday, October 27, 2011 8:37 PM