Convert this sendgrid example to

How could I use the following code in an aspx.cs page? I haven’t worked with Task objects before.

using System;
using System.Threading.Tasks;
using SendGrid;
using SendGrid.Helpers.Mail;

class Program
    static async Task Main()
        var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
        var client = new SendGridClient(apiKey);
        var from = new EmailAddress("", "Example User");
        var subject = "Sending with Twilio SendGrid is Fun";
        var to = new EmailAddress("", "Example User");
        var plainTextContent = "and easy to do anywhere, even with C#";
        var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
        var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
        var response = await client.SendEmailAsync(msg).ConfigureAwait(false);


I'm yet to test the solution mentioned in the comments. I'm trusting it doesn't have an ASP.NET blocking issue described in: