Add extension method to set mail item as read/unread and apply method to beacon messages.
authorThomas
Tue, 15 Nov 2016 15:04:37 +0100
changeset 14442458d5d2d562
parent 1443 78d95419b562
child 1445 db3006473994
Add extension method to set mail item as read/unread and apply method to beacon messages.
CryptableMailItem.cs
Extensions/MailItemExtensions.cs
Extensions/StoreExtensions.cs
Interfaces.cs
MsgContainer.cs
MsgConverter.cs
PEPAttachment.cs
PEPIdentity.cs
     1.1 --- a/CryptableMailItem.cs	Tue Nov 15 13:07:07 2016 +0100
     1.2 +++ b/CryptableMailItem.cs	Tue Nov 15 15:04:37 2016 +0100
     1.3 @@ -878,6 +878,7 @@
     1.4                          {
     1.5                              // Only one category is needed to hide the MailItem -- delete any others
     1.6                              this.internalMailItem.Categories = Globals.PEP_INTERNAL_CATEGORY_NAME;
     1.7 +                            this.internalMailItem.SetIsRead(true);
     1.8                              preProcessingPropertySet = true;
     1.9                          }
    1.10                      }
     2.1 --- a/Extensions/MailItemExtensions.cs	Tue Nov 15 13:07:07 2016 +0100
     2.2 +++ b/Extensions/MailItemExtensions.cs	Tue Nov 15 15:04:37 2016 +0100
     2.3 @@ -1273,6 +1273,53 @@
     2.4          }
     2.5  
     2.6          /// <summary>
     2.7 +        /// Sets or deletes the Read flag.
     2.8 +        /// </summary>
     2.9 +        /// <param name="omi">The Outlook mail item to process with.</param>
    2.10 +        /// <param name="newReadValue">Whether this mail item should be flagged as read or unread.</param>
    2.11 +        public static void SetIsRead(this Outlook.MailItem omi, bool newReadValue)
    2.12 +        {
    2.13 +            Int32 messageFlags;
    2.14 +            bool isRead = false;
    2.15 +            bool valueChanged = false;
    2.16 +
    2.17 +            if (omi != null)
    2.18 +            {
    2.19 +                // Detect using MAPI message flags
    2.20 +                messageFlags = (Int32)MapiHelper.GetProperty(omi, MapiProperty.PidTagMessageFlags, (Int32)0);
    2.21 +
    2.22 +                if ((messageFlags & ((Int32)MapiPropertyValue.EnumPidTagMessageFlags.mfRead)) > 0)
    2.23 +                {
    2.24 +                    isRead = true;
    2.25 +                }
    2.26 +
    2.27 +                if ((isRead) &&
    2.28 +                    (newReadValue == false))
    2.29 +                {
    2.30 +                    messageFlags -= (Int32)MapiPropertyValue.EnumPidTagMessageFlags.mfRead;
    2.31 +                    valueChanged = true;
    2.32 +                }
    2.33 +                else if ((isRead == false) &&
    2.34 +                         (newReadValue))
    2.35 +                {
    2.36 +                    messageFlags += (Int32)MapiPropertyValue.EnumPidTagMessageFlags.mfRead;
    2.37 +                    valueChanged = true;
    2.38 +                }
    2.39 +
    2.40 +                if (valueChanged)
    2.41 +                {
    2.42 +                    try
    2.43 +                    {
    2.44 +                        MapiHelper.SetProperty(omi, MapiProperty.PidTagMessageFlags, messageFlags);
    2.45 +                    }
    2.46 +                    catch { }
    2.47 +                }
    2.48 +            }
    2.49 +
    2.50 +            return;
    2.51 +        }
    2.52 +
    2.53 +        /// <summary>
    2.54          /// Sets a value to either a UserProperty or MAPI property in the given outlook mail item.
    2.55          /// NOTE: The MailItem will NOT be automatically saved, this MUST be done externally for the property to be persistent.
    2.56          /// Warning: The propertyName for a UserProperty or MAPI property must never be the same.
     3.1 --- a/Extensions/StoreExtensions.cs	Tue Nov 15 13:07:07 2016 +0100
     3.2 +++ b/Extensions/StoreExtensions.cs	Tue Nov 15 15:04:37 2016 +0100
     3.3 @@ -11,7 +11,7 @@
     3.4      {
     3.5          /// <summary>
     3.6          /// Determines if the given Outlook store has pEp enabled by comparing against the account settings.
     3.7 -        /// The assumption is each account has it's own unique data store (which may not be true for POP3).
     3.8 +        /// The assumption is each account has its own unique data store (which may not be true for POP3).
     3.9          /// </summary>
    3.10          /// <param name="store">The Outlook store to process with.</param>
    3.11          /// <returns>True if the Outlook store has pEp enabled, otherwise false.</returns>
    3.12 @@ -111,7 +111,7 @@
    3.13  
    3.14          /// <summary>
    3.15          /// Determines if the given outlook store is to store messages securely by comparing against the account settings.
    3.16 -        /// The assumption is each account has it's own unique data store (which may not be true for POP3).
    3.17 +        /// The assumption is each account has its own unique data store (which may not be true for POP3).
    3.18          /// </summary>
    3.19          /// <param name="store">The Outlook store to process with.</param>
    3.20          /// <returns>True if the outlook store is to store messages securely, otherwise false.</returns>
     4.1 --- a/Interfaces.cs	Tue Nov 15 13:07:07 2016 +0100
     4.2 +++ b/Interfaces.cs	Tue Nov 15 15:04:37 2016 +0100
     4.3 @@ -11,19 +11,19 @@
     4.4          public interface ICopy<T>
     4.5          {
     4.6              /// <summary>
     4.7 -            /// Gets a deep copy of the object and all it's data.
     4.8 +            /// Gets a deep copy of the object and all its data.
     4.9              /// </summary>
    4.10              /// <returns>The deep copy of the object.</returns>
    4.11              T Copy(); 
    4.12          }
    4.13  
    4.14          /// <summary>
    4.15 -        /// Interface to support resetting an object to it's default state/values.
    4.16 +        /// Interface to support resetting an object to its default state/values.
    4.17          /// </summary>
    4.18          public interface IReset
    4.19          {
    4.20              /// <summary>
    4.21 -            /// Resets the object to it's default state/values.
    4.22 +            /// Resets the object to its default state/values.
    4.23              /// </summary>
    4.24              void Reset();
    4.25          }
     5.1 --- a/MsgContainer.cs	Tue Nov 15 13:07:07 2016 +0100
     5.2 +++ b/MsgContainer.cs	Tue Nov 15 15:04:37 2016 +0100
     5.3 @@ -197,7 +197,7 @@
     5.4          }
     5.5  
     5.6          /// <summary>
     5.7 -        /// Resets the object to it's default state/values.
     5.8 +        /// Resets the object to its default state/values.
     5.9          /// </summary>
    5.10          public void Reset()
    5.11          {
    5.12 @@ -281,7 +281,7 @@
    5.13          }
    5.14  
    5.15          /// <summary>
    5.16 -        /// Gets a deep copy of the object and all it's data.
    5.17 +        /// Gets a deep copy of the object and all its data.
    5.18          /// </summary>
    5.19          /// <returns>The deep copy of the object.</returns>
    5.20          public MsgContainer Copy()
     6.1 --- a/MsgConverter.cs	Tue Nov 15 13:07:07 2016 +0100
     6.2 +++ b/MsgConverter.cs	Tue Nov 15 15:04:37 2016 +0100
     6.3 @@ -144,7 +144,7 @@
     6.4          /// Flags used during conversion of Mails using <see cref="IConverterSession.MAPIToMIMEStm"/>.
     6.5          /// </summary>
     6.6          /// <remarks>The documentation mentions CCSF_EMBEDDED_MESSAGE to persist the Sent/Unsent
     6.7 -        /// information in a X-Unsent header, but does not document it's bit value...</remarks>
     6.8 +        /// information in a X-Unsent header, but does not document its bit value...</remarks>
     6.9          [Flags]
    6.10          public enum CCSF// : int
    6.11          {
     7.1 --- a/PEPAttachment.cs	Tue Nov 15 13:07:07 2016 +0100
     7.2 +++ b/PEPAttachment.cs	Tue Nov 15 15:04:37 2016 +0100
     7.3 @@ -424,7 +424,7 @@
     7.4          }
     7.5  
     7.6          /// <summary>
     7.7 -        /// Gets a deep copy of the object and all it's data.
     7.8 +        /// Gets a deep copy of the object and all its data.
     7.9          /// </summary>
    7.10          /// <returns>The deep copy of the object.</returns>
    7.11          public PEPAttachment Copy()
     8.1 --- a/PEPIdentity.cs	Tue Nov 15 13:07:07 2016 +0100
     8.2 +++ b/PEPIdentity.cs	Tue Nov 15 15:04:37 2016 +0100
     8.3 @@ -460,7 +460,7 @@
     8.4          }
     8.5  
     8.6          /// <summary>
     8.7 -        /// Gets a deep copy of the object and all it's data.
     8.8 +        /// Gets a deep copy of the object and all its data.
     8.9          /// </summary>
    8.10          /// <returns>The deep copy of the object.</returns>
    8.11          public PEPIdentity Copy()
    8.12 @@ -545,7 +545,7 @@
    8.13  
    8.14          /// <summary>
    8.15          /// Recursivley converts the given identity into a 'flat' list of any members.
    8.16 -        /// This will remove groups (hierarchy) and convert a group into it's members.
    8.17 +        /// This will remove groups (hierarchy) and convert a group into its members.
    8.18          /// </summary>
    8.19          /// <param name="identity">The identity to get the flat list for.</param>
    8.20          /// <returns>The flat list of pEp identities in the identity.</returns>
    8.21 @@ -1945,7 +1945,7 @@
    8.22  
    8.23          /// <summary>
    8.24          /// Recursivley converts the given identities into a 'flat' list of any members.
    8.25 -        /// This will remove groups (hierarchy) and convert a group into it's members.
    8.26 +        /// This will remove groups (hierarchy) and convert a group into its members.
    8.27          /// The list will be build by calling each identity's .ToFlatList method.
    8.28          /// </summary>
    8.29          /// <param name="identities">The identities to get the flat list for.</param>