Skip to content

Instantly share code, notes, and snippets.

@namitts82
Last active April 20, 2016 04:43
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 namitts82/5a2561358622422143cea9170c06076d to your computer and use it in GitHub Desktop.
Save namitts82/5a2561358622422143cea9170c06076d to your computer and use it in GitHub Desktop.
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