I'm developing an addin which needs to store some data on the mailitems. I'm using Redemption library and MAPI.Utils HrSetOneProp method.
Only in Outlook 2016, I get "Error in IMAPIProp::SaveChanges: MAPI_E_OBJECT_CHANGED" every time I do a second call to the method on the same mailitem.
Tried using Redemption RDO objects, and also plain OOM with the same results.
Here is an example:
SafeMailItem m = RedemptionGM9.SafeMailItem;
m.Item = mailItem; // this mailitem came as parameter in the function and it is the activeExplorer slection
MAPIUtils utils = RedemptionGM9.MAPIUtils;
string sGUID = PS_PUBLIC_STRINGS.ToString("B");
int iID = m.GetIDsFromNames(sGUID, GMLINK);
if (iID != 0)
{
//this is the method that is failing every second time for the same mailitem until you restart outlook.
utils.HrSetOneProp(mailItem.MAPIOBJECT, iID, bForceGMPropTrue ? true : !String.IsNullOrEmpty(sAccNo), true);
}
Marshal.ReleaseComObject(utils);
utils = null;
Marshal.ReleaseComObject(m);
m = null;
//mailitem com object is released outside this method