public static MailMessage SetHtmlBody(this MailMessage mailMessage, string htmlBody, IDictionary <string, string> textReplacementKeys,
                                              IDictionary <string, string> imageFilePathReplacementKeys, string imageContentType = "image/png")
        {
            var resourceReplacements = new Dictionary <string, LinkedResource>();

            if (imageFilePathReplacementKeys != null)
            {
                foreach (var imageReplacement in imageFilePathReplacementKeys)
                {
                    resourceReplacements.Add(imageReplacement.Key, new LinkedResource(imageReplacement.Value,
                                                                                      new ContentType(imageContentType))
                    {
                        ContentId = Guid.NewGuid().ToString()
                    });
                }
            }

            return(mailMessage.SetHtmlBody(htmlBody, textReplacementKeys, resourceReplacements));
        }
        public static MailMessage SetHtmlBody(this MailMessage mailMessage, string htmlBody, IDictionary <string, string> textReplacementKeys,
                                              IDictionary <string, byte[]> imageContentReplacementKeys, string imageContentType = "image/png")
        {
            var resourceReplacements = new Dictionary <string, LinkedResource>();

            if (imageContentReplacementKeys != null)
            {
                foreach (var imageReplacement in imageContentReplacementKeys)
                {
                    resourceReplacements.Add(imageReplacement.Key, new LinkedResource(new MemoryStream(imageReplacement.Value),
                                                                                      new ContentType(imageContentType))
                    {
                        ContentId        = Guid.NewGuid().ToString(),
                        TransferEncoding = TransferEncoding.Base64,
                    });
                }
            }

            return(mailMessage.SetHtmlBody(htmlBody, textReplacementKeys, resourceReplacements));
        }
 public static MailMessage SetHtmlBody(this MailMessage mailMessage, string htmlBody, IDictionary <string, string> textReplacementKeys = null)
 {
     return(mailMessage.SetHtmlBody(htmlBody, textReplacementKeys, (IDictionary <string, LinkedResource>)null));
 }