Consider the following scenario:
- You create an email message by using Microsoft Outlook.
- You attach an existing email message to the new message.
- You open the attached message for viewing.
- You use the NewInspector event to get a reference to the current Outlook.MailItem that corresponds to the email attachment that you just opened.
- From the MailItem object, you get a reference to the underlying MAPI object by reading the MAPIOBJECT property in C++.
- You save the message or Outlook initiates an AutoSave operation.
- You start the GetProps method on an IMAPIProp reference from the MAPIOBJECT reference that you obtained through the NewInspector event.
In this scenario, Outlook crashes.
The MAPI object that you obtained from the MAPIOBJECT property has become stale and is no longer usable. You should not reuse the property if the corresponding Outlook item has changed.
Every time that you have to run an operation on the MAPI object that maps to an Outlook or Outlook Object Model item, you should get a new reference to the underlying MAPI object. Then, run any MAPI operations on that new reference instead of on a stale reference that might no longer be valid. Using a stale reference might cause unexpected behavior and crash the Outlook client.
We recommend that you do not hold onto any MAPIOBJECT references that you obtained through the Outlook Object Model for longer than necessary. This is because the underlying object is frequently subject to change. Using a stale underlying object might cause unexpected errors.
This applies to all scenarios in which you might have to get a MAPIOBJECT reference through the Outlook Object Model, not only the scenario that is mentioned in the "Symptoms" section.