如何从 aspx.vb 页面调用 SendGrid?

问题描述

我正在尝试从 https://github.com/sendgrid/sendgrid-csharp 工作中获取 SendGrid 简单示例:

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("test@example.com","Example User");
        var subject = "Sending with Twilio SendGrid is Fun";
        var to = new EmailAddress("test@example.com","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);
    }
}

我需要将其转换为 ASP.NET VB.NET,但首先我想弄清楚如何从 aspx.cs 页面调用该 Main 方法

在 aspx.cs 页面中,我会做 C# 等价的:

Dim c As New Program()
With c
   .Main()
End With

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)