/// <summary> /// Cancels the sending of notifications. /// </summary> public void UnRegisteEvents() { if (ulConnection_ != 0) { MAPIStore.Unadvise(ulConnection_); } if (pAdviseSink_ != null) { pAdviseSink_ = null; } }
/// <summary> /// Registers to receive notification of specified events that affect the message store. /// </summary> /// <param name="eventMask">A mask of values that indicate the types of notification events that the caller is interested in and should be included in the registration. </param> /// <returns></returns> public bool RegisterEvents(EEventMask eventMask) { callbackHandler_ = new OnAdviseCallbackHandler(OnNotifyCallback); HRESULT hresult = HRESULT.S_OK; try { pAdviseSink_ = new MAPIAdviseSink(IntPtr.Zero, callbackHandler_); hresult = MAPIStore.Advise(0, IntPtr.Zero, (uint)eventMask, pAdviseSink_, out ulConnection_); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return(false); } return(hresult == HRESULT.S_OK); }