gpt4 book ai didi

email - 如何使用 SendGrid 在 Microsoft Azure 中发送电子邮件

转载 作者:行者123 更新时间:2023-12-02 07:41:46 25 4
gpt4 key购买 nike

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

最佳答案

您需要从 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("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4d5d6d7f4cccdce9ad7dbd9" rel="noreferrer noopener nofollow">[email protected]</a>", "Abc Xyz");
myMessage.Subject = emailSubject;
myMessage.Text = emailBody;

// Create credentials, specifying your user name and password. (Use SendGrid UserId & Password
var credentials = new NetworkCredential("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="24455e5156417b5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c64455e5156410a474b49" rel="noreferrer noopener nofollow">[email protected]</a>", "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

关于email - 如何使用 SendGrid 在 Microsoft Azure 中发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23124675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com