Pregunta

In our MAPI message store provider, we present both email and non-outlook items (office documents etc). Technically, we provide these documents as an IMessage object with a single attachment and a specific PR_MESSAGE_CLASS (e.g. IPM.Document.txtfile) . Outlook then considers this object to be a DocumentItem, not a MailItem.

As you can see in the screenshot below, this works fine. Previewer works as expected, double clicking the item will open the item in the appropriate application (e.g. Notepad).

Before opening - preview works fine

However, after the item has been opened, once the external application closes, something goes amiss. The preview breaks, and the item can not be opened again until another item is selected first.

After opening - preview breaks, opening breaks

According to Outlook Spy, our IMessage object is still perfectly fine. It is the OOM DocumentItem wrapper that is now somehow missing it's attachment:

DocumentItem Missing attachment

What could be causing this behavior? Is there a refresh we are missing? Is the Outlook item presenting an old IMessage object that has gone corrupt? We've spend quite a bit of research on this topic already, all pointers are welcome!

[EDIT 1]

Here is Outlook spy stating our IMessage object is still ok:

IMessage still fine

[EDIT 2]

As long as the external application doesn't close, everything is fine. I can open the document as many times as I want, but as soon as I close a single instance of the external viewer the Outlook item gets "corrupted".

¿Fue útil?

Solución

The answer turned out to be really simple,

The PR_MESSAGE_FLAGS property needs to include MSGFLAG_HASATTACH

Adding this flag immediately fixed the issue, and makes perfect sense. It's just that the resulting behavior of Outlook (working at first access, then breaking) threw us off.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top