[英]Azure SendGrid doesn't send any email and raises no error
I just created my SendGrid account an hour ago. 一个小时前,我刚刚创建了我的SendGrid帐户。 I then created a C# Console app on my PC using the sample code from Microsoft .
然后,我使用Microsoft的示例代码在PC上创建了C#控制台应用程序。 It runs fine, without any error message, but sends no email and leaves no trace in the system.
它运行正常,没有任何错误消息,但没有发送电子邮件,也没有在系统中留下任何痕迹。 What shall I do?
我该怎么办?
using System;
using System.Net;
using System.Net.Mail;
using SendGrid;
using System.Collections;
using System.Collections.Generic;
namespace SendGridTest
{
class Program
{
static void Main(string[] args)
{
var myMessage = new SendGridMessage();
myMessage.From = new MailAddress("noreply@teacherspet.net.au");
List<String> recipients = new List<String>
{
@"my1@gmail.com",
@"my2@gmail.com",
@"my3@gmail.com"
};
myMessage.AddTo(recipients);
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Html = "<p>Hello World!</p>";
var credentials = new NetworkCredential("azure_6e0d0...@azure.com", "mypassword");
var transportWeb = new Web(credentials);
transportWeb.DeliverAsync(myMessage);
}
}
}
As Brendan Green suggested, once changed the last line to 正如布伦丹·格林(Brendan Green)所建议的,将最后一行更改为
transportWeb.DeliverAsync(myMessage).Wait();
it worked. 有效。 Thanks Brendan!
谢谢布伦丹!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.