当前位置: 首页>>代码示例>>C#>>正文


C# SendGridMessage.EmbedImage方法代码示例

本文整理汇总了C#中SendGrid.SendGridMessage.EmbedImage方法的典型用法代码示例。如果您正苦于以下问题:C# SendGridMessage.EmbedImage方法的具体用法?C# SendGridMessage.EmbedImage怎么用?C# SendGridMessage.EmbedImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SendGrid.SendGridMessage的用法示例。


在下文中一共展示了SendGridMessage.EmbedImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_EmbedImage_listlinkedresource

        public void Test_EmbedImage_listlinkedresource()
        {
            var filename = new string[] { Path.GetTempFileName(), Path.GetTempFileName() };
            var attachments = filename.ToList().ConvertAll<Attachment>((x) => { return new Attachment(x); });
            var linkedResources = filename.ToList().ConvertAll<LinkedResource>((x) => { return new LinkedResource(x); });

            var mail = BasicMailBuilder
                .EmbedImages(linkedResources)
                .Build();

            var message = new SendGridMessage();
            message.AddAttachment(attachments[0].ContentStream, attachments[0].Name);
            message.AddAttachment(attachments[1].ContentStream, attachments[1].Name);
            message.EmbedImage(linkedResources[0].ContentId, linkedResources[0].ContentId);
            message.EmbedImage(linkedResources[1].ContentId, linkedResources[1].ContentId);
            CollectionAssert.AreEquivalent(message.GetEmbeddedImages().ToList(), mail.GetEmbeddedImages().ToList());
            Assert.AreEqual(2, message.StreamedAttachments.Count);
            Assert.AreEqual(2, mail.StreamedAttachments.Count);
            Assert.AreEqual(message.StreamedAttachments.First().Value.Length, mail.StreamedAttachments.First().Value.Length);
            Assert.AreEqual(message.StreamedAttachments.Last().Value.Length, mail.StreamedAttachments.Last().Value.Length);
        }
开发者ID:saluce65,项目名称:sendgrid-csharp-mailbuilder,代码行数:21,代码来源:UnitTest1.cs

示例2: Test_EmbedImage_linkedresource

        public void Test_EmbedImage_linkedresource()
        {
            var filename = Path.GetTempFileName();
            var attachment = new Attachment(filename);
            var linkedResource = new LinkedResource(filename);

            var mail = BasicMailBuilder
                .EmbedImage(linkedResource)
                .Build();

            var message = new SendGridMessage();
            message.AddAttachment(attachment.ContentStream, attachment.Name);
            message.EmbedImage(linkedResource.ContentId, linkedResource.ContentId);
            CollectionAssert.AreEquivalent(message.GetEmbeddedImages().ToList(), mail.GetEmbeddedImages().ToList());
            Assert.AreEqual(1, message.StreamedAttachments.Count);
            Assert.AreEqual(1, mail.StreamedAttachments.Count);
            Assert.AreEqual(message.StreamedAttachments.First().Value.Length, mail.StreamedAttachments.First().Value.Length);
        }
开发者ID:saluce65,项目名称:sendgrid-csharp-mailbuilder,代码行数:18,代码来源:UnitTest1.cs

示例3: Test_EmbedImage_linkedresourcecollection

        public void Test_EmbedImage_linkedresourcecollection()
        {
            var filename = Path.GetTempFileName();
            var attachment = new Attachment(filename);
            var av = AlternateView.CreateAlternateViewFromString("Testing");
            av.LinkedResources.Add(new LinkedResource(filename));

            var mail = BasicMailBuilder
                .EmbedImages(av.LinkedResources)
                .Build();

            var message = new SendGridMessage();
            message.AddAttachment(attachment.ContentStream, attachment.Name);
            message.EmbedImage(av.LinkedResources[0].ContentId, av.LinkedResources[0].ContentId);
            CollectionAssert.AreEquivalent(message.GetEmbeddedImages().ToList(), mail.GetEmbeddedImages().ToList());
            Assert.AreEqual(1, message.StreamedAttachments.Count);
            Assert.AreEqual(1, mail.StreamedAttachments.Count);
            Assert.AreEqual(message.StreamedAttachments.First().Value.Length, mail.StreamedAttachments.First().Value.Length);
        }
开发者ID:saluce65,项目名称:sendgrid-csharp-mailbuilder,代码行数:19,代码来源:UnitTest1.cs

示例4: Test_EmbedImage_filepath_cid

        public void Test_EmbedImage_filepath_cid()
        {
            var filename = Path.GetTempFileName();
            var cid = "[email protected]";
            var mail = BasicMailBuilder
                .EmbedImage(filename, cid)
                .Build();

            var message = new SendGridMessage();
            message.AddAttachment(filename);
            message.EmbedImage(new FileInfo(filename).Name, cid);

            CollectionAssert.AreEquivalent(message.GetEmbeddedImages().ToList(), mail.GetEmbeddedImages().ToList());
            CollectionAssert.AreEquivalent(message.Attachments, mail.Attachments);
            CollectionAssert.AreEquivalent(message.StreamedAttachments, mail.StreamedAttachments);
        }
开发者ID:saluce65,项目名称:sendgrid-csharp-mailbuilder,代码行数:16,代码来源:UnitTest1.cs


注:本文中的SendGrid.SendGridMessage.EmbedImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。