How to: Determine whether an Outlook item has been modified but not saved (Outlook Auxiliary Reference)

Office 2013 and later

This topic shows how to use the dispidFDirty dispatch ID to invoke the corresponding property on an Outlook item, to see whether the item has been modified and has not been saved.

Given an item object, you can use the IUnknown::QueryInterface method to obtain an IDispatch interface pointer. The function in this topic, FIsItemDirty, accepts an IDispatch pointer, pdisp, as an input parameter. FIsItemDirty calls the IDispatch::Invoke method, specifying dispidFDirty as the argument for the dispIdMember parameter, and the flags DISPATCH_METHOD | DISPATCH_PROPERTYGET for wFlags, to verify whether the item has been modified. FIsItemDirty returns a Boolean value (True to indicate that the item has unsaved changes; otherwise, False).

bool FIsItemDirty(IDispatch *pdisp)
    DISPPARAMS dispparams;
    UINT uArgErr;
    HRESULT hr = S_OK;
    CComVariant varDirty;
    dispparams.rgvarg = 0;
    dispparams.cArgs = 0;
    dispparams.cNamedArgs = 0;
    dispparams.rgdispidNamedArgs = NULL;
    hr = pdisp->Invoke(dispidFDirty,
    return SUCCEEDED(hr) && varDirty.bVal;