Skip to content

Instantly share code, notes, and snippets.

@sjwaight
Last active November 27, 2016 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjwaight/9cd20d2cfc2730aedafeb3762b3887ab to your computer and use it in GitHub Desktop.
Save sjwaight/9cd20d2cfc2730aedafeb3762b3887ab to your computer and use it in GitHub Desktop.
Azure Function that uses a SendGrid output binding to send email.
#r "Microsoft.Azure.WebJobs.Extensions.SendGrid"
using SendGrid.Helpers.Mail;
public static void run(out Mail message)
{
// see the associted function.json & projcet.json files for how to get this working.
// function.json: https://gist.github.com/sjwaight/1394817ab84f8b6688a11be8621364fb
// project.json: https://gist.github.com/sjwaight/0c2392236b56ef914f0b4b10b786a8fb
// NOTE: no need to set the 'sender/from' property as the output binding does that for us.
var personalization = new Personalization();
personalization.AddTo(new Email("simon.waight@kloud.com.au"));
var messageContent = new Content("text/html", "My fantastic mail body contents here.");
message = new Mail();
message.AddContent(messageContent);
message.AddPersonalization(personalization);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment