Do not set KeyImport header to outer message OUT-541
authorThomas
Fri, 01 Mar 2019 10:48:34 +0100
branchOUT-541
changeset 2584 c5a783090136
parent 2583 8e5312ca6ba5
child 2585 a8fd38d6ec9d
Do not set KeyImport header to outer message
PEPMessage.cs
ThisAddIn.cs
UI/KeySyncWizard.xaml.cs
--- a/PEPMessage.cs	Fri Mar 01 08:27:33 2019 +0100
+++ b/PEPMessage.cs	Fri Mar 01 10:48:34 2019 +0100
@@ -2847,6 +2847,7 @@
                     {
                         newMessage.KeyImport = transportHeaders?.FirstOrDefault(a => (a.Field == PEPMessage.PR_PEP_KEY_IMPORT_NAME || a.Field == PEPMessage.PR_PEP_KEY_IMPORT_NAME_OLD))?.Value?.Trim();
 
+                        // Check backup solution with ReplyTo tunnel if needed
                         if (string.IsNullOrEmpty(newMessage.KeyImport) &&
                             (newMessage.ReplyTo?.Count > 0))
                         {
--- a/ThisAddIn.cs	Fri Mar 01 08:27:33 2019 +0100
+++ b/ThisAddIn.cs	Fri Mar 01 10:48:34 2019 +0100
@@ -794,8 +794,7 @@
         internal void CreateAndSendMessage(PEPMessage message,
                                            bool deleteAfterSend,
                                            bool validateSendingAccount,
-                                           bool processMessage = false,
-                                           bool setKeyImportHeader = false)
+                                           bool processMessage = false)
         {
             Outlook.MailItem newItem;
             Globals.ReturnStatus sts;
@@ -828,31 +827,9 @@
                     MapiHelper.SetProperty(newItem, MapiProperty.PidLidUseTnef, false);
 
                     // If ForceUnencrypted property is set, add it to mail item
-                    bool save = false;
                     if (message.ForceUnencrypted)
                     {
                         newItem.SetPEPProperty(MailItemExtensions.PEPProperty.ForceUnencrypted, true);
-                        save = true;
-                    }
-
-                    // Set KeyImport header if necessary
-                    if (setKeyImportHeader)
-                    {
-                        newItem.SetPEPProperty(MailItemExtensions.PEPProperty.KeyImport, message.KeyImport);
-                        save = true;
-                    }
-
-                    // Save if necessary
-                    if (save)
-                    {
-                        try
-                        {
-                            newItem.Save();
-                        }
-                        catch (Exception ex)
-                        {
-                            Log.Error("CreateAndSendMessage: Error saving new item. " + ex.ToString());
-                        }
                     }
 
                     /* Send
--- a/UI/KeySyncWizard.xaml.cs	Fri Mar 01 08:27:33 2019 +0100
+++ b/UI/KeySyncWizard.xaml.cs	Fri Mar 01 10:48:34 2019 +0100
@@ -1651,7 +1651,7 @@
                             }
 
                             // Send message
-                            Globals.ThisAddIn.CreateAndSendMessage(message, true, true, processMessage, true);
+                            Globals.ThisAddIn.CreateAndSendMessage(message, true, true, processMessage);
 
                             // Log that message has been sent
                             this.sentMessages?.Add(messageType);