OUT-453: Added isInline property and set it in all attachments depending on ContentId presence in mail HTML body. Assign ContentId if attachment is inline OUT-453
authornikolaj
Wed, 23 May 2018 11:01:49 +0200
branchOUT-453
changeset 2209bebcde071bec
parent 2208 7051e9283317
child 2210 505c19ee49d3
OUT-453: Added isInline property and set it in all attachments depending on ContentId presence in mail HTML body. Assign ContentId if attachment is inline
PEPAttachment.cs
PEPMessage.cs
     1.1 --- a/PEPAttachment.cs	Tue May 22 16:25:09 2018 +0200
     1.2 +++ b/PEPAttachment.cs	Wed May 23 11:01:49 2018 +0200
     1.3 @@ -42,7 +42,7 @@
     1.4          private string _FileName;
     1.5          private string _MimeType;
     1.6          private byte[] _Tag;
     1.7 -
     1.8 +        private bool   _isInline;
     1.9          private static object                       mutexCache              = new object();
    1.10          private static Dictionary<string, Icon>     iconCache               = new Dictionary<string, Icon>();
    1.11  
    1.12 @@ -140,6 +140,13 @@
    1.13           * 
    1.14           *************************************************************/
    1.15  
    1.16 +
    1.17 +        /// <summary>
    1.18 +        /// Gets if attachment is inline
    1.19 +        /// </summary>
    1.20 +        public bool IsInline { get { return this._isInline; } }
    1.21 +
    1.22 +
    1.23          /// <summary>
    1.24          /// Gets or sets the unique ID (within message) of the attachment.
    1.25          /// This matches a corresponding "cid:" URI schema reference in the HTML body of the Message object.
    1.26 @@ -822,8 +829,8 @@
    1.27                      MapiHelper.SetProperty(newAttachment, MapiProperty.PidTagAttachTag, this._Tag);
    1.28                  }
    1.29  
    1.30 -                // Set the content ID
    1.31 -                if (string.IsNullOrWhiteSpace(this._ContentId) == false)
    1.32 +                // Set the content ID if attachment is inline
    1.33 +                if (string.IsNullOrWhiteSpace(this._ContentId) == false && _isInline == true)
    1.34                  {
    1.35                      MapiHelper.SetProperty(newAttachment, MapiProperty.PidTagAttachContentId, this._ContentId);
    1.36                  }
    1.37 @@ -1045,5 +1052,27 @@
    1.38  
    1.39              return (data);
    1.40          }
    1.41 +
    1.42 +        /// <summary>
    1.43 +        /// Sets Inline field depending on ContentId presence in mail HTML body
    1.44 +        /// </summary>
    1.45 +        /// <param name="html"></param>
    1.46 +        public void SetInline(string html)
    1.47 +        {
    1.48 +            if(string.IsNullOrEmpty(this._ContentId) || string.IsNullOrEmpty(html))
    1.49 +            {
    1.50 +                this._isInline = false;
    1.51 +                return;
    1.52 +            }
    1.53 +
    1.54 +            if (html.Contains(this._ContentId))
    1.55 +            {
    1.56 +                this._isInline = true;
    1.57 +            }
    1.58 +            else
    1.59 +            {
    1.60 +                this._isInline = false;
    1.61 +            }
    1.62 +        }
    1.63      }
    1.64  }
     2.1 --- a/PEPMessage.cs	Tue May 22 16:25:09 2018 +0200
     2.2 +++ b/PEPMessage.cs	Wed May 23 11:01:49 2018 +0200
     2.3 @@ -1876,6 +1876,9 @@
     2.4                      }
     2.5                  }
     2.6  
     2.7 +                // Sets Inline field in all attachments depending on ContentId presence in mail HTML body 
     2.8 +                _Attachments.ForEach(a => a.SetInline(_LongMsgFormattedHtml));
     2.9 +
    2.10                  if (isPGPMIMEMsg)
    2.11                  {
    2.12                      PEPAttachment pgpMIME = this.ConvertToPGPMIMEAttachment();