Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
namespace VSOBugReporter
{
public class Functions
{
/// <summary>
/// Sends an email using sendgrid
/// </summary>
/// <param name="message">message body</param>
private void SendMail(string message)
{
//From address
string fromAddress = "bugreporter@azurebootcamp.com";
//To address
string toAddress = "destination@hotmail.com";
//Instantiate SendGrid object
var myMessage = new SendGridMessage();
myMessage.From = new MailAddress(fromAddress);
myMessage.AddTo(toAddress);
myMessage.Subject = "Visual Studio Bug Report " + DateTime.Now.ToShortDateString();
myMessage.Html = message;
//Your SendGrid API key here
var apiKey = "**** Your API Key here **** ";
var transportWeb = new Web(apiKey);
//Post Email
transportWeb.DeliverAsync(myMessage);
}
/// <summary>
/// Report Bug function triggered by VSO Web Hook
/// </summary>
/// <param name="body">JSON body</param>
/// <param name="trace">Trace object</param>
public static void ReportBug([WebHookTrigger] string body, TraceWriter trace)
{
trace.Info("Sending Bug report");
WeatherReport weatherReport = new WeatherReport();
sendmail(body);
trace.Info("Bug report sent");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment