OUT-277: Do not process items in Sent folders of untrusted accounts
authorThomas
Thu, 22 Jun 2017 09:30:38 +0200
changeset 171858aa0058d282
parent 1717 1bf7ab2fe080
child 1720 359e4a00b68e
OUT-277: Do not process items in Sent folders of untrusted accounts
ThisAddIn.cs
     1.1 --- a/ThisAddIn.cs	Thu Jun 22 08:57:05 2017 +0200
     1.2 +++ b/ThisAddIn.cs	Thu Jun 22 09:30:38 2017 +0200
     1.3 @@ -1486,34 +1486,26 @@
     1.4                              this.watchedFolders.Add(new WatchedFolder(folder, Outlook.OlDefaultFolders.olFolderInbox));
     1.5                          }
     1.6  
     1.7 -                        /* Add Sent folder if account type is ActiveSync (to delete beacons and decrypt if necessary)
     1.8 -                         * or if Outlook Version is 2010 or earlier. In the latter case, this serves to set the custom
     1.9 -                         * message class "IPM.Note.Secure.pEp" to the mail item, which is needed so that the unencrypted 
    1.10 -                         * preview on untrusted servers is always visible on the first click.
    1.11 -                         */
    1.12 -                        if (store.GetIsAccountType(Outlook.OlAccountType.olEas) || 
    1.13 -                            Globals.GetOutlookVersion() == Globals.Version.Outlook2010)
    1.14 +                        // Add Sent folder. This is needed so sent mails get decrypted on trusted servers to make the search function working
    1.15 +                        try
    1.16                          {
    1.17 -                            try
    1.18 -                            {
    1.19 -                                folder = (Outlook.Folder)store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
    1.20 -                            }
    1.21 -                            catch
    1.22 -                            {
    1.23 -                                if (folder != null)
    1.24 -                                {
    1.25 -                                    // Marshal.ReleaseComObject(folder);
    1.26 -                                    folder = null;
    1.27 -                                }
    1.28 -
    1.29 -                                Log.Warning("ConnectWatchedFolders: Failure getting default sent folder");
    1.30 -                            }
    1.31 -
    1.32 -                            // Add the folder to the watched list (do not release it)
    1.33 +                            folder = (Outlook.Folder)store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
    1.34 +                        }
    1.35 +                        catch
    1.36 +                        {
    1.37                              if (folder != null)
    1.38                              {
    1.39 -                                this.watchedFolders.Add(new WatchedFolder(folder, Outlook.OlDefaultFolders.olFolderSentMail));
    1.40 +                                // Marshal.ReleaseComObject(folder);
    1.41 +                                folder = null;
    1.42                              }
    1.43 +
    1.44 +                            Log.Warning("ConnectWatchedFolders: Failure getting default sent folder");
    1.45 +                        }
    1.46 +
    1.47 +                        // Add the folder to the watched list (do not release it)
    1.48 +                        if (folder != null)
    1.49 +                        {
    1.50 +                            this.watchedFolders.Add(new WatchedFolder(folder, Outlook.OlDefaultFolders.olFolderSentMail));
    1.51                          }
    1.52  
    1.53                          //Marshal.ReleaseComObject(store);
    1.54 @@ -4168,7 +4160,21 @@
    1.55                           */
    1.56                          else if (CryptableMailItem.IsInCopiedItemsList(omi?.EntryID) == false)
    1.57                          {
    1.58 -                            process = true;
    1.59 +                            // Do not process Sent folders of secure stores (not needed)
    1.60 +                            if ((omi.GetIsInSecureStore()) &&
    1.61 +                                (this.defaultFolder == Outlook.OlDefaultFolders.olFolderSentMail))
    1.62 +                            {
    1.63 +                                if (Globals.GetOutlookVersion() == Globals.Version.Outlook2010)
    1.64 +                                {
    1.65 +                                    MapiHelper.SetProperty(omi, MapiProperty.PidTagMessageClass, MapiPropertyValue.PidTagMessageClassSecurePEP);
    1.66 +                                    omi.Save();
    1.67 +                                }
    1.68 +                            }
    1.69 +                            else
    1.70 +                            {
    1.71 +                                process = true;
    1.72 +                            }
    1.73 +
    1.74                          }
    1.75  
    1.76                          if (process)