Пример #1
0
        /// <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);
        }
 /// <summary>
 /// Initializes a new instance of the MAPIAdviseSink class. 
 /// </summary>
 /// <param name="pContext">object pointer</param>
 /// <param name="callbackHandler">callback delegate</param>
 public MAPIAdviseSink(IntPtr pContext, OnAdviseCallbackHandler callbackHandler)
 {
     pContext_ = pContext;
     callbackHandler_ = callbackHandler;
 }
 /// <summary>
 /// Initializes a new instance of the MAPIAdviseSink class.
 /// </summary>
 /// <param name="pContext">object pointer</param>
 /// <param name="callbackHandler">callback delegate</param>
 public MAPIAdviseSink(IntPtr pContext, OnAdviseCallbackHandler callbackHandler)
 {
     pContext_        = pContext;
     callbackHandler_ = callbackHandler;
 }
 public MAPIAdviseSink(IMsgStore store, EEventMask eventMask, IMAPISession owner)
 {
     this.store = store;
     IntPtr ptr = IntPtr.Zero;
     this.callbackHandler = OnNotifyCallback;
     HRESULT hr = MAPIlibAdvise(store.Ptr, eventMask, this.callbackHandler, ref ptr);
     if (hr != HRESULT.S_OK)
         throw new Exception("MAPIlibAdvise failed: " + hr.ToString());
     this.adviserPtr = ptr;
     this.owner = owner;
 }
 private static extern HRESULT MAPIlibAdvise(IntPtr storePtr, EEventMask eventMask, OnAdviseCallbackHandler callback, ref IntPtr adviser);
Пример #6
0
 /// <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;
 }