Do not modify mail body in Outlook 2010 OUT-418 ForceProtection2010
authorThomas
Mon, 26 Mar 2018 16:07:54 +0200
branchOUT-418 ForceProtection2010
changeset 2083a757627c791d
parent 2082 6a58c6f05ce1
child 2088 e293ddf764ad
Do not modify mail body in Outlook 2010
FPPMessage.cs
     1.1 --- a/FPPMessage.cs	Mon Mar 26 16:06:33 2018 +0200
     1.2 +++ b/FPPMessage.cs	Mon Mar 26 16:07:54 2018 +0200
     1.3 @@ -274,45 +274,52 @@
     1.4  
     1.5                                  if (omi != null)
     1.6                                  {
     1.7 -                                    // Modify message body
     1.8 -                                    try
     1.9 +                                    /* Modify message body to adjust wording. Do not modify it on Outlook 2010,
    1.10 +                                     * as this internally replaces the mail item which will then get reloaded
    1.11 +                                     * and processed again, resulting in sending out one Answer Message after
    1.12 +                                     * the other.
    1.13 +                                     */
    1.14 +                                    if (Globals.GetOutlookVersion() != Globals.Version.Outlook2010)
    1.15                                      {
    1.16 -                                        omi.Body = FPPMessage.PEP_FPP_MESSAGE_BODY_PLAIN_PEP_INSTALLED;
    1.17 -                                        omi.HTMLBody = FPPMessage.PEP_FPP_MESSAGE_BODY_HTML_PEP_INSTALLED;
    1.18 -                                        omi.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
    1.19 -                                    }
    1.20 -                                    catch (Exception ex)
    1.21 -                                    {
    1.22 -                                        Log.Error("ContinueProcessing: Error changing mail body. " + ex.ToString());
    1.23 -                                    }
    1.24 +                                        try
    1.25 +                                        {
    1.26 +                                            omi.Body = FPPMessage.PEP_FPP_MESSAGE_BODY_PLAIN_PEP_INSTALLED;
    1.27 +                                            omi.HTMLBody = FPPMessage.PEP_FPP_MESSAGE_BODY_HTML_PEP_INSTALLED;
    1.28 +                                            omi.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
    1.29 +                                        }
    1.30 +                                        catch (Exception ex)
    1.31 +                                        {
    1.32 +                                            Log.Error("ContinueProcessing: Error changing mail body. " + ex.ToString());
    1.33 +                                        }
    1.34  
    1.35 -                                    // Remove key
    1.36 -                                    Outlook.Attachments attachments = null;
    1.37 -                                    Outlook.Attachment attachment = null;
    1.38 -                                    try
    1.39 -                                    {
    1.40 -                                        attachments = omi.Attachments;
    1.41 -                                        for (int i = 1; i <= attachments.Count; i++)
    1.42 +                                        // Remove key
    1.43 +                                        Outlook.Attachments attachments = null;
    1.44 +                                        Outlook.Attachment attachment = null;
    1.45 +                                        try
    1.46                                          {
    1.47 -                                            attachment = attachments[i];
    1.48 -                                            var pEpAttachment = new PEPAttachment(attachment);
    1.49 -                                            if (pEpAttachment.IsKey)
    1.50 +                                            attachments = omi.Attachments;
    1.51 +                                            for (int i = 1; i <= attachments.Count; i++)
    1.52                                              {
    1.53 -                                                attachments.Remove(i);
    1.54 -                                                i--;
    1.55 +                                                attachment = attachments[i];
    1.56 +                                                var pEpAttachment = new PEPAttachment(attachment);
    1.57 +                                                if (pEpAttachment.IsKey)
    1.58 +                                                {
    1.59 +                                                    attachments.Remove(i);
    1.60 +                                                    i--;
    1.61 +                                                }
    1.62 +                                                attachment = null;
    1.63                                              }
    1.64 +                                        }
    1.65 +                                        catch (Exception ex)
    1.66 +                                        {
    1.67 +                                            Log.Error("ContinueProcessing: Error removing key. " + ex.ToString());
    1.68 +                                        }
    1.69 +                                        finally
    1.70 +                                        {
    1.71 +                                            attachments = null;
    1.72                                              attachment = null;
    1.73                                          }
    1.74                                      }
    1.75 -                                    catch (Exception ex)
    1.76 -                                    {
    1.77 -                                        Log.Error("ContinueProcessing: Error removing key. " + ex.ToString());
    1.78 -                                    }
    1.79 -                                    finally
    1.80 -                                    {
    1.81 -                                        attachments = null;
    1.82 -                                        attachment = null;
    1.83 -                                    }
    1.84  
    1.85                                      // Set message class if necessary
    1.86                                      if (omi.GetIsSecurelyStored())