本文整理汇总了C#中SendGrid.SendGridMessage.AddUniqueArgs方法的典型用法代码示例。如果您正苦于以下问题:C# SendGridMessage.AddUniqueArgs方法的具体用法?C# SendGridMessage.AddUniqueArgs怎么用?C# SendGridMessage.AddUniqueArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SendGrid.SendGridMessage
的用法示例。
在下文中一共展示了SendGridMessage.AddUniqueArgs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_IncludeUniqueArgs
public void Test_IncludeUniqueArgs()
{
var args = new Dictionary<string, string>() {
{ "key1", "value"},
{ "key2", "eulav" }
};
var mail = BasicMailBuilder
.IncludeUniqueArgs(args)
.Build();
var message = new SendGridMessage();
message.AddUniqueArgs(args);
Assert.IsFalse(string.IsNullOrEmpty(message.Header.JsonString()));
Assert.AreEqual(message.Header.JsonString(), mail.Header.JsonString());
}
示例2: AddUniqueIdentifiers
/// <summary>
/// This feature adds key value identifiers to be sent back as arguments over the event api for
/// various events
/// </summary>
public void AddUniqueIdentifiers()
{
//create a new message object
var message = new SendGridMessage();
//set the message recipients
foreach (var recipient in _to)
{
message.AddTo(recipient);
}
//set the sender
message.From = new MailAddress(_from);
//set the message body
message.Text = "Hello World";
//set the message subject
message.Subject = "Testing Unique Identifiers";
var identifiers = new Dictionary<String, String>();
identifiers["customer"] = "someone";
identifiers["location"] = "somewhere";
message.AddUniqueArgs(identifiers);
//create an instance of the SMTP transport mechanism
var transportInstance = new Web(new NetworkCredential(_username, _password));
//enable bypass list management
message.EnableBypassListManagement();
//send the mail
transportInstance.DeliverAsync(message);
}