I am new to Sendgrid and have made a small console app to test it:
static void Main(string[] args)
{
Execute().Wait();
}
static async Task Execute()
{
try
{
var apiKey = "XX.XXXXXX-R-XXXXXX_XXXXX.XXXXXXXXXXXXXXXXX_XXXXXXXXXXXXXXXXXXXXXX";
var client = new SendGridClient(apiKey);
var from = new EmailAddress(xxxxxxxx@xxxxxxx.com", "Me");
var subject = "Test";
var to = new EmailAddress("xxxxxxxx@xxxxxxx.com", "You");
var plainTextContent = "Test";
var htmlContent = "Test";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Console.WriteLine(response.Headers.ToString());
Console.Read();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.Read();
}
}
When I run this, I get output which suggests it has been accepted (there are no errors, and the StatusCode is accepted):
Accepted
Connection: keep-alive
X-Message-Id: N2e7faW9TuC38K25dUVFlQ
Access-Control-Allow-Origin: https://sendgrid.api-docs.io
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: Authorization, Content-Type, On-behalf-of, x-sg-elas-acl
Access-Control-Max-Age: 600
X-No-CORS-Reason: https://sendgrid.com/docs/Classroom/Basics/API/cors.html
Date: Tue, 28 Nov 2017 15:24:32 GMT
Server: nginx
but I never receive the email, and the stats on SendGrid show 0 mails sent.
I've checked Junk, Clutter, Anti-Spam and the message definitely isn't arriving. What am I missing?