本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}