/// <summary>
 /// Initializes a new instance of the MsgStoreNewMailEventArgs class. 
 /// </summary>
 /// <param name="storeID">The entry identification of message store.</param>
 /// <param name="notification">The new mail notification structure.</param>
 public MsgStoreNewMailEventArgs(EntryID storeID, NEWMAIL_NOTIFICATION notification)
 {
     StoreID = storeID;
     SBinary sbEntry = new SBinary() { cb = notification.cbEntryID, lpb = notification.pEntryID };
     SBinary sbParent = new SBinary() { cb = notification.cbParentID, lpb = notification.pParentID };
     EntryID = sbEntry.cb > 0 ? new EntryID(sbEntry.AsBytes) : null;
     ParentID = sbParent.cb > 0 ? new EntryID(sbParent.AsBytes) : null;
     MessageFlags = (int)notification.MessageFlags;
     if ((notification.Flags & (uint)CharacterSet.UNICODE) == (uint)CharacterSet.UNICODE)
         MessageClass = Marshal.PtrToStringUni(notification.MessageClass);
     else
         MessageClass = Marshal.PtrToStringAnsi(notification.MessageClass);
 }
Ejemplo n.º 2
0
        void OnNotifyCallback(IntPtr pContext, uint cNotification, IntPtr lpNotifications)
        {
            EEventMask eventType = (EEventMask)Marshal.ReadInt32(lpNotifications);
            int        intSize   = Marshal.SizeOf(typeof(int));
            IntPtr     sPtr      = lpNotifications + intSize * 2; //ulEventType, ulAlignPad

            switch (eventType)
            {
            case EEventMask.fnevNewMail:
            {
                Console.WriteLine("New mail");
                if (this.OnNewMail == null)
                {
                    break;
                }
                NEWMAIL_NOTIFICATION     notification = (NEWMAIL_NOTIFICATION)Marshal.PtrToStructure(sPtr, typeof(NEWMAIL_NOTIFICATION));
                MsgStoreNewMailEventArgs n            = new MsgStoreNewMailEventArgs(StoreID, notification);
                this.OnNewMail(this, n);
            }
            break;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the MsgStoreNewMailEventArgs class.
        /// </summary>
        /// <param name="storeID">The entry identification of message store.</param>
        /// <param name="notification">The new mail notification structure.</param>
        public MsgStoreNewMailEventArgs(EntryID storeID, NEWMAIL_NOTIFICATION notification)
        {
            StoreID = storeID;
            SBinary sbEntry = new SBinary()
            {
                cb = notification.cbEntryID, lpb = notification.pEntryID
            };
            SBinary sbParent = new SBinary()
            {
                cb = notification.cbParentID, lpb = notification.pParentID
            };

            EntryID      = sbEntry.cb > 0 ? new EntryID(sbEntry.AsBytes) : null;
            ParentID     = sbParent.cb > 0 ? new EntryID(sbParent.AsBytes) : null;
            MessageFlags = (int)notification.MessageFlags;
            if ((notification.Flags & (uint)CharacterSet.UNICODE) == (uint)CharacterSet.UNICODE)
            {
                MessageClass = Marshal.PtrToStringUni(notification.MessageClass);
            }
            else
            {
                MessageClass = Marshal.PtrToStringAnsi(notification.MessageClass);
            }
        }