Esempio n. 1
0
        public void ChangeSmileLinks()
        {
            var base_smile_url = SmileToAttachmentConvertor.SmileBaseUrl;

            var doc = new HtmlDocument();

            doc.LoadHtml(HtmlBody);
            var link_nodes = doc.DocumentNode.SelectNodes("//img[@src and (contains(@src,'" + base_smile_url + "'))]");

            if (link_nodes != null)
            {
                var smile_convertor = new SmileToAttachmentConvertor();
                foreach (var link_node in link_nodes)
                {
                    var link   = link_node.Attributes["src"].Value;
                    var attach = smile_convertor.ToMailAttachment(link);
                    link_node.SetAttributeValue("src", "cid:" + attach.contentId);

                    if (AttachmentsEmbedded.All(x => x.contentId != attach.contentId))
                    {
                        AttachmentsEmbedded.Add(attach);
                    }
                }
                HtmlBody = doc.DocumentNode.OuterHtml;
            }
        }
Esempio n. 2
0
        public void ChangeSmileLinks()
        {
            var base_smile_url = SmileToAttachmentConvertor.SmileBaseUrl;

            var doc = new HtmlDocument();
            doc.LoadHtml(HtmlBody);
            var link_nodes = doc.DocumentNode.SelectNodes("//img[@src and (contains(@src,'" + base_smile_url + "'))]");
            if (link_nodes != null)
            {
                var smile_convertor = new SmileToAttachmentConvertor();
                foreach (var link_node in link_nodes)
                {
                    var link = link_node.Attributes["src"].Value;
                    _logger.Info("ChangeSmileLinks() Link to smile: {0}", link);
                    var attach = smile_convertor.ToMailAttachment(link);
                    _logger.Info("ChangeSmileLinks() Embedded smile contentId: {0}", attach.contentId);
                    link_node.SetAttributeValue("src", "cid:" + attach.contentId);

                    if (AttachmentsEmbedded.All(x => x.contentId != attach.contentId))
                    {
                        AttachmentsEmbedded.Add(attach);
                    }
                }
                HtmlBody = doc.DocumentNode.OuterHtml;
            }
        }