Send SMTP Mail spend 4 seconds

I am utilizing Codeunit 400 (SMTP Mail) to send email. The function works well. However, it takes about 4-second to send an email. Any idea why it takes so long time? Anyway to shorten time to 0.5 second? My Nav version is NAV 2013.



Is there any attachment with mail ??

When you say it takes 4 seconds, how are you measuring that? From what event to what evant takes 4 seconds?

Let me explain what I tried to do:

  • I would like to send a background email when any user unblock an item card.

  • Here is the simple program inside Item Card, “Blocked - OnValidate()”

IF (Rec.Blocked = xRec.Blocked ) OR (Blocked = TRUE ) THEN EXIT;


Smail.CreateMessage( … );

SmailSent; //Smail is Codeunit SMTP Mail.

No any attachment in the email, just a few texts.

  • The 4-second is counted starting from user click the Blocked check box, until it become blank.

During that 4 seconds, user may move mouse cursor but is not able to “focus” or click-to-edit any other fields in NAV. NAV just no response before it shows the item is unbloked. However, if user click other objects or programs (such as Start, IE, or any icon ) during that 4-second, Windows will response immediately.

  • As you may guess, if user don’t know it will “hang” for 4-second, the user will try clicking the check box multiple times…

The 4-second is way too long to response to user.



Sent time depends on contains and server /machine speed,Internet speed,Load on exchange server.

In this case I suggest put one message box saying ‘Mail Being Sent .Kindly wait’ and once mail sent flash message saying’Mail Sent’

are you using thsi code on the page…?

then why not try it on the table field onvalidate…?

because that interacts much faster with the codeunits…than rtc pages…

this is how rtc pages interact with cal code…

they fidn the temporary page in the server location

they call the c# code onvalidate of the textbox trigger… then they interact with the cal code in ur server…

since you code is again going through SMTP… that is how i anticipate the delay here…

why currpage.update function…?

as ur are not changing any values through code…? just sending an email after it is unblocked…

also why the condition and exit… why not execute the code… with another condition if the blocked = false

for example u can try

if blocked = false and rec.blocked <> xrec.blocked then

sendmail()–> smtp sendmail commads.

see if you can try this in the table trigger rather than page

so try with tables trigger rather than page…


Thanks for your advise. I did try code in both table and page but get the same result. The delay is not caused by the page.

Why put in page and use CurrPage.Update? Originally I put code in table. I move it to page just try to see where if “CurrPage.Update” will make the “Blocked” checkup shows unblocked before sending email. But, obviously it did not work as I thought… The CurrPage.Update is not useful at all. Remove it did not help either :slight_smile:

No matter how, thank for giving a hand.


We have 90% confidence level that the server speed, internet speed or loading of SMTP server are NOT the root problem, since we had tried it in an isolated and very simple LAN.

No matter how, thanks for giving a hand.



Also my experience that SMTP male take 5 to 6 seconds to send an email. Using SMTP with Office 365.

I solved the issue with the standard Job Queues in NAV 2013. Just put the document you want to email in the Job Queue Entry tabel en process it in background with a NAS.