Я пытаюсь интегрировать Sendgrid для отправки электронной почты, но получаю сообщение об ошибке. >
Вот мой код, который я пробовал и который тоже вызывает ошибку. Кто-нибудь может мне помочь?
Код: Выделить всё
public void Email_ALL()
{
try
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;
var sendclient = new SendGridClient("api-key");
var from = new EmailAddress("hello@test.com", "Test");
var subject = "Sending with Twilio SendGrid is Fun";
var to = new EmailAddress("Test@gmail.com", "Example User");
var plainTextContent = "and easy to do anywhere, even with C#";
var htmlContent = "[b]and easy to do anywhere, even with C#[/b]";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var result = Task.Run(() => sendclient.SendEmailAsync(msg)).GetAwaiter().GetResult();
}
catch (Exception ex)
{
throw ex;
}
}
Система .Net.Http.HttpRequestException: «При отправке запроса произошла ошибка».
SocketException: существующее соединение было принудительно закрыто удаленным хостом

Подробнее здесь: https://stackoverflow.com/questions/793 ... -net-4-5-2
Мобильная версия