Hello - how can I make this method async?
public class SendEmail
{
public void sendPostFailMessage()
{ var apiKey = "";
var client = new SendGridClient(apiKey);
var from = new EmailAddress("test123@gmail.com", "Test");
var subject = "Error";
var to = new EmailAddress("Test221@gmail.com", "Testtest");
var plainTextContent = "and easy to do anywhere, even with C#";
var htmlContent =
"Hello, <br><br> There has been an is";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = client.SendEmailAsync(msg).Wait(10000);
}
}
public class StartService : IStartService
{
private readonly SendEmail _sendEmail;
public async Task GenerateAndSendJson()
{
foreach (var item in fromDatabase)
{
Console.WriteLine("Sending data");
try
{
}
catch
{
_sendEmail.sendPostFailMessage();
continue;
}
}
Console.WriteLine("Process finish");
}
}