OUT-542: Avoid creation of Winmail.dat attachments during background processing
authorThomas
Tue, 05 Mar 2019 11:22:29 +0100
changeset 2593c266c7e55440
parent 2592 fef273b2d6e4
child 2594 b4351ec5c330
child 2595 8b720212bbdf
OUT-542: Avoid creation of Winmail.dat attachments during background processing
Extensions/MailItemExtensions.cs
ThisAddIn.cs
     1.1 --- a/Extensions/MailItemExtensions.cs	Mon Mar 04 14:47:39 2019 +0100
     1.2 +++ b/Extensions/MailItemExtensions.cs	Tue Mar 05 11:22:29 2019 +0100
     1.3 @@ -52,7 +52,8 @@
     1.4          {
     1.5              Undefined,
     1.6              ProcessInBackground,
     1.7 -            Processed
     1.8 +            Processed,
     1.9 +            ProcessedAvoidWinmailDat
    1.10          }
    1.11  
    1.12          // Default values for pEp properties.
    1.13 @@ -340,6 +341,8 @@
    1.14              omi?.DeleteUserProperty(CryptableMailItem.USER_PROPERTY_KEY_ENABLE_PROTECTION);
    1.15              omi?.DeleteUserProperty(CryptableMailItem.USER_PROPERTY_KEY_IS_ORIGINALLY_ENCRYPTED);
    1.16              omi?.DeleteUserProperty(CryptableMailItem.USER_PROPERTY_KEY_ORIGINAL_RATING);
    1.17 +            omi?.DeleteUserProperty(MailItemExtensions.USER_PROPERTY_KEY_ORIG_ENTRY_ID);
    1.18 +            omi?.DeleteUserProperty(MailItemExtensions.USER_PROPERTY_KEY_PROCESSING_STATE);
    1.19  
    1.20              // Do not allow TNEF/RTF format with 'winmail.dat' attachment
    1.21              MapiHelper.SetProperty(omi, MapiProperty.PidLidUseTnef, false);
    1.22 @@ -2036,10 +2039,13 @@
    1.23                      // Avoid creation of 'winmail.dat' attachment if needed
    1.24                      if (processedMessage.IsSecure == false)
    1.25                      {
    1.26 -                        omi.AvoidWinmailDatAttachment();
    1.27 +                        omi.SetProcessingState(MailItemExtensions.ProcessingState.ProcessedAvoidWinmailDat);
    1.28                      }
    1.29 -
    1.30 -                    omi.SetProcessingState(MailItemExtensions.ProcessingState.Processed);
    1.31 +                    else
    1.32 +                    {
    1.33 +                        omi.SetProcessingState(MailItemExtensions.ProcessingState.Processed);
    1.34 +                    }
    1.35 +
    1.36                      omi.Send();
    1.37                  }
    1.38                  catch (Exception ex)
     2.1 --- a/ThisAddIn.cs	Mon Mar 04 14:47:39 2019 +0100
     2.2 +++ b/ThisAddIn.cs	Tue Mar 05 11:22:29 2019 +0100
     2.3 @@ -3313,6 +3313,12 @@
     2.4                          Log.Verbose("Application_ItemSend: Message already processed. Sending directly...");
     2.5                          return;
     2.6                      }
     2.7 +                    else if (processingState == MailItemExtensions.ProcessingState.ProcessedAvoidWinmailDat)
     2.8 +                    {
     2.9 +                        Log.Verbose("Application_ItemSend: Message already processed. Preventing Winmail.dat and sending directly...");
    2.10 +                        omi.AvoidWinmailDatAttachment();
    2.11 +                        return;
    2.12 +                    }
    2.13  
    2.14                      // Check for special cases
    2.15                      bool processMessage = true;