Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tests & use case for From personalization #1137

Merged
merged 6 commits into from
Nov 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions ExampleCoreProject/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using SendGrid;
using SendGrid.Helpers.Mail;

namespace Example
{
internal class ExampleEmail
{
private static void Main()
{
Execute().Wait();
}

static async Task Execute()
{
var apiKey = "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";
beebzz marked this conversation as resolved.
Show resolved Hide resolved
var client = new SendGridClient(apiKey);
var from = new EmailAddress("team_intrapersonalfaces@devinterfaces.com");
var subject = "Hello from Twilio SendGrid";

var msg = new SendGridMessage();
msg.Subject = subject;
msg.AddContent(MimeType.Text, "Hello from fakegrid, please work");
msg.SetFrom(from);

msg.Personalizations = new List<Personalization>() {
new Personalization() {
Tos = new List<EmailAddress>() {
new EmailAddress("bboussayoud@colgate.edu")
},
},
new Personalization() {
Tos = new List<EmailAddress>() {
new EmailAddress("bilal.boussayoud@gmail.com")
},
From = new EmailAddress("team_nofaces@devinterfaces.com")
},
};
var response = await client.SendEmailAsync(msg);

Console.WriteLine(msg.Serialize());
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Headers.ToString());
Console.WriteLine("\n\nPress any key to exit.");
Console.ReadLine();
}
}
}