【问题标题】:How to send email in Microsoft Azure using SendGrid [closed]如何使用 SendGrid 在 Microsoft Azure 中发送电子邮件 [关闭]
【发布时间】:2014-04-17 04:35:26
【问题描述】:

在 Microsoft Azure 网站中,我们如何使用 SendGrid 发送电子邮件?

【问题讨论】:

    标签: email azure sendgrid


    【解决方案1】:

    您需要从 Azure 获取 SendGrid UserId & Key,然后使用以下代码发送电子邮件:

    public void SendEmail(string emailTo, string emailSubject, string emailBody)
    {
        try
        {
            //Create the email object first, then add the properties.
            SendGrid myMessage = SendGrid.GetInstance();
            myMessage.AddTo(emailTo);
            myMessage.From = new MailAddress("abc@xyz.com", "Abc Xyz");
            myMessage.Subject = emailSubject;
            myMessage.Text = emailBody;
    
            // Create credentials, specifying your user name and password. (Use SendGrid UserId & Password
            var credentials = new NetworkCredential("azure_xxxxxxxxxxxxxxx@azure.com", "xxxxxxxxxxxx");
    
            // Create an Web transport for sending email.
            var transportWeb = Web.GetInstance(credentials);
    
            //Send the email.
            transportWeb.DeliverAsync(myMessage);
        }
        catch (Exception ex)
        {
            string msg = ex.Message;
        }
    }
    

    更多信息您可以参考以下链接http://sendgrid.com/docs/Code_Examples/csharp.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      • 2018-10-23
      • 1970-01-01
      相关资源
      最近更新 更多