Skip to content

Instantly share code, notes, and snippets.

@thinkingserious
Created September 29, 2015 18:07
Show Gist options
  • Save thinkingserious/14208711bd6ee49c8eb5 to your computer and use it in GitHub Desktop.
Save thinkingserious/14208711bd6ee49c8eb5 to your computer and use it in GitHub Desktop.
SendGrid CSharp Test
var myMessage = new SendGridMessage();
myMessage.From = new MailAddress("[email protected]");
myMessage.AddTo("[email protected]");
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Text = "Hello World";
var sg_username = Environment.GetEnvironmentVariable("SENDGRID_USERNAME");
var sg_password = Environment.GetEnvironmentVariable("SENDGRID_PASSWORD");
var credentials = new NetworkCredential(sg_username, sg_password);
var transportWeb = new Web(credentials);
transportWeb.DeliverAsync(myMessage);
@white-label-development

In my tests problems lay with
await transportWeb.DeliverAsync(myMessage);
or
transportWeb.DeliverAsync(myMessage).Wait();

in that the Task never returned (even though the message was sent to the SendGrid api) which made me wonder if the thread was being lost within the DeliverAsync function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment