Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

'Failure sending mail. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.'

(0) ShareShare
ReportReport
Posted on by 85

Hi everyone I have implemented some mail sending functionality to send(Posted Sales Invoices) with custom email body, when I try to send multiple it send few of them and show message that enable to send email, If I try to debug it show them following error.

Please suggest a solution design change or code imporvement thanks

7217.SMTP-error.png

CLEARALL();
SMTPSetup.GET;
IF customer.GET(SalesHeaders."Sell-to Customer No." )THEN
 customer.TESTFIELD("E-Mail");
 CompanyInfo.GET();
 WITH TempEmailItem DO BEGIN
      "From Address" := SMTPSetup."User ID";
      "Send to" := customer."E-Mail";
      Subject := CompanyInfo.Name ' - Invoice '   SalesHeaders."No.";
      GenerateEmailBody(SalesHeaders, EmailBody);
      Body := EmailBody.Blob;
      "Attachment File Path":= GenerateEmailAttachment(SalesHeader."No.");;
      "Attachment Name" := 'Sales Invoice ' SalesHeader."No." '.pdf';
      "Plaintext Formatted" := FALSE;
      EXIT(Send(TRUE));
 END;

  • bruno.a.paulo@outlook.pt Profile Picture
    5 on at
    RE: 'Failure sending mail. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.'

    Hi Abdullah Zafar,

    Can you send a print of the function "TrySend" of codeunit "400" please

  • Verified answer
    Abdullah Zafar Profile Picture
    85 on at
    RE: 'Failure sending mail. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.'

    Thank you Marco Mels , The issue was due to the TLS version, to resolve I had added dotnet variable in function TrySend of codeunit 400. I have followed this guide from Erik Hougaard  

    Link www.hougaard.com/.../

    Best Regards

  • Verified answer
    Marco Mels Profile Picture
    on at
    RE: 'Failure sending mail. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.'

    Hello,

    Usually this error related to Tls1.2 requirements that are not met. The forum has a few suggestions that you can follow up on, using registry. Tls1.2 was only added in Dynamics NAV xxx in a specific cumulative update.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,000 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans