Sendgrid-csharp: Remote name could not be resolved.

Created on 19 May 2017  Â·  2Comments  Â·  Source: sendgrid/sendgrid-csharp

Hello,
I have an issue with SDK version 9.1.0

The code that gets that issue

var client = new SendGridClient(_sendGridAPIKey);
var msg = new SendGridMessage();
msg.AddTo(new EmailAddress(to));
msg.From = new EmailAddress(from);
msg.Subject = subject;

if (isHtml)
{
    msg.HtmlContent = text;
}
else
   msg.PlainTextContent = text;

if (attachement != null && attachement.Length > 0)
{
    SendGrid.Helpers.Mail.Attachment attachment = new SendGrid.Helpers.Mail.Attachment();
    var file = Convert.ToBase64String(attachement);
    msg.AddAttachment(content, file);
}

var response = client.SendEmailAsync(msg);

Error message
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote name could not be resolved: ‘api.sendgrid.com’

at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at SendGrid.SendGridClient.d__19.MoveNext() in C:\Users\elmer\Documents\GitHub\sendgrid-csharp\src\SendGrid\SendGridClient.cs:line 212

Technical details:

  • sendgrid-csharp Version: 9.1.0
  • .NET Version: 4.6.1
help wanted non-library issue question

Most helpful comment

@veranyan This is not library issue, please check your DNS settings , it seem like you are having local connectivity issue. can you put your code in retry?

All 2 comments

@veranyan This is not library issue, please check your DNS settings , it seem like you are having local connectivity issue. can you put your code in retry?

@paritoshmmmec yes, I will try tomorrow and let you know

Was this page helpful?
0 / 5 - 0 ratings