本文整理汇总了C#中SendGrid.SendGridMessage.EnableBypassListManagement方法的典型用法代码示例。如果您正苦于以下问题:C# SendGridMessage.EnableBypassListManagement方法的具体用法?C# SendGridMessage.EnableBypassListManagement怎么用?C# SendGridMessage.EnableBypassListManagement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SendGrid.SendGridMessage
的用法示例。
在下文中一共展示了SendGridMessage.EnableBypassListManagement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSubstitutionValues
/// <summary>
/// This feature allows you to create a message template, and specify different replacement
/// strings for each specific recipient
/// </summary>
public void AddSubstitutionValues()
{
//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 = "Hi %name%! Pleased to meet you!";
//set the message subject
message.Subject = "Testing Substitution Values";
//This replacement key must exist in the message body
var replacementKey = "%name%";
//There should be one value for each recipient in the To list
var substitutionValues = new List<String> { "Mr Foo", "Mrs Raz" };
message.AddSubstitution(replacementKey, substitutionValues);
//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);
}
示例2: Test_EnablingBypassListManagement
public void Test_EnablingBypassListManagement()
{
var mail = BasicMailBuilder
.EnableBypassListManagement()
.Build();
var message = new SendGridMessage();
message.EnableBypassListManagement();
Assert.IsFalse(string.IsNullOrEmpty(message.Header.JsonString()));
Assert.AreEqual(message.Header.JsonString(), mail.Header.JsonString());
}
示例3: 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);
}
示例4: SetCategory
/// <summary>
/// This feature tags the message with a specific tracking category, which will have aggregated stats
/// viewable from your SendGridMessage account page.
/// </summary>
public void SetCategory()
{
//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 Categories";
var category = "vipCustomers";
message.SetCategory(category);
//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);
}
示例5: EnableBypassListManagementEmail
/// <summary>
/// This feature wraps an HTML template around your email content.
/// This can be useful for sending out newsletters and/or other HTML formatted messages.
/// hhttp://docs.sendgrid.com/documentation/apps/email-templates/
/// </summary>
public void EnableBypassListManagementEmail()
{
//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
var timestamp = DateTime.Now.ToString("HH:mm:ss tt");
message.Html = "<p style='color:red';>Hello World</p>";
message.Html += "<p>Sent At : " + timestamp + "</p>";
message.Text = "Hello World plain text";
//set the message subject
message.Subject = "Hello World Bypass List Management Test";
//create an instance of the Web transport mechanism
var transportInstance = new Web(new NetworkCredential(_username, _password));
//enable bypass list management
message.EnableBypassListManagement();
//send the mail
transportInstance.DeliverAsync(message);
}
示例6: SendEmailViaSendGrid
public static void SendEmailViaSendGrid(string to, string from, string subject, string htmlBody, MailType type, string textBody, string[] multipleTo = null)
{
try
{
//var message = SendGrid.GenerateInstance();
var message = new SendGridMessage();
if (String.IsNullOrEmpty(to))
message.AddTo(multipleTo);
else
message.AddTo(to);
//if (multipleTo != null)
// message.AddTo(multipleTo);
//else
// message.AddTo(to);
message.From = new System.Net.Mail.MailAddress(from);
message.Subject = subject;
if (type == MailType.TextOnly)
message.Text = textBody.Replace(@"\r\n", Environment.NewLine);
else if (type == MailType.HtmlOnly)
message.Html = htmlBody;
else
{
message.Html = htmlBody;
message.Text = textBody;
}
//Dictionary<string, string> collection = new Dictionary<string, string>();
//collection.Add("header", "header");
//message.Headers = collection;
message.EnableOpenTracking();
message.EnableClickTracking();
message.DisableUnsubscribe();
message.DisableFooter();
message.EnableBypassListManagement();
//var transportInstance = SMTP.GenerateInstance(new System.Net.NetworkCredential(SendGridUsername, SendGridPassword), SendGridSmtpHost, SendGridSmtpPort);
var transportInstance = new Web(new System.Net.NetworkCredential(SendGridUsername, SendGridPassword));
transportInstance.Deliver(message);
if (String.IsNullOrEmpty(to))
Console.WriteLine("SendGrid: Email was sent successfully to " + multipleTo);
else
Console.WriteLine("SendGrid: Email was sent successfully to " + to);
}
catch (Exception)
{
if (String.IsNullOrEmpty(to))
Console.WriteLine("SendGrid: Unable to send email to " + multipleTo);
else
Console.WriteLine("SendGrid: Unable to send email to " + to);
throw;
}
}
示例7: EnableBypassListManagement
public void EnableBypassListManagement()
{
var header = new Header();
var sendgrid = new SendGridMessage(header);
sendgrid.EnableBypassListManagement();
var json = header.JsonString();
Assert.AreEqual("{\"filters\" : {\"bypass_list_management\" : {\"settings\" : {\"enable\" : \"1\"}}}}", json);
}