venus najad

venus najad

  • 1.3k
  • 414
  • 27.5k

An existing connection was forcibly closed by the remote host

Aug 9 2024 7:42 PM

hello everyone. for contactus in C# asp net webform, i have used sendgrid and for that the following codes:

protected async void btnSend_Click(object sender, EventArgs e)
        {
            emailfrom = txtEmail.Text;
            sub = txtSubject.Text;
            body = txtBody.Text;
            await Execute().ConfigureAwait(false);
        }

        static async Task Execute()
        {
            var apiKey = "my key"; 
            var client = new SendGridClient(apiKey);
            var from = new EmailAddress(emailfrom, "someone");
            var subject = sub;// "Sending with SendGrid is Fun";
            var to = new EmailAddress("[email protected]", "venus");
            var plainTextContent = body;// "and i check if it works";
            var htmlContent = "<strong>" + body + "</strong>";
            var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
            var response = await client.SendEmailAsync(msg).ConfigureAwait(false);
            System.Diagnostics.Debug.WriteLine(response.StatusCode);
            System.Diagnostics.Debug.WriteLine(response.Body.ReadAsStringAsync());

i get error: An existing connection was forcibly closed by the remote host

i appreciate your help to fix this error... i dont know how to eventually fix SSL or TSL

 


Answers (2)