Help / WLanguage / WLanguage functions / Communication / Managing emails
  • Managing emails in asynchronous mode
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Returns the status of an email sent via an SMTP session started in asynchronous mode.
// Send an email via the SMTP protocol
IF EmailStartSession(USER, PASSWORD, "", ...
"", 110, 25, True) = True THEN
UserName = USER
UserName = ""
Error("Unable to establish the connection")
// Initialize the email structure
Email.Recipient = ""
Email.Sender = ""
Email.Message = "Auto Email Test"
Email.NbRecipient = 1
// Send the email
IF EmailSendMessage(UserName) = False THEN
Error("EMailSendMessage failed '" + ErrorInfo(errMessage) + "'")
Info("EmailSendMessage was successful")
// Track the email
SWITCH EmailStatus(Email.MailIdentifier)
CASE emailSent: Trace("The email was sent")
CASE emailPending: Trace("The email is currently processed")
CASE emailError: Trace("Error: " + ErrorInfo(errMessage))
<Result> = EmailStatus(<Email Identifier>)
<Result>: Constant
Outgoing status of the specified email:
emailErrorAn error occurred. The error details are returned by ErrorInfo(errMessage).
emailPendingThe email is waiting to be sent. It is in the spooler.
emailSentThe email was sent.
<Email Identifier>: Integer
Email identifier (Email.MailIdentifier variable or ID property of the Email variable initialized when the email was sent with EmailSend and EmailSendMessage).

Managing emails in asynchronous mode

The email functions are locking functions by default. Which means that no other code can be run during their execution. The program will resume only when the current Email functions have been run.
WEBDEV gives you the ability to manage the emails in asynchronous mode. This mode allows your sites to send emails without locking the execution of other processes.
To use the asynchronous mode, you must:
  1. Uncheck "Disable the email spooler" in the WEBDEV administrator ("Advanced" tab).
  2. Enable the asynchronous mode when starting the SMTP session (with EmailStartSMTPSession or EmailStartSession).
  3. All outgoing emails will be transmitted to a "spooler". Emails are queued up before being sent.
Executing Email functions does no longer block the rest of the program. EmailStatus determines the status of an email.
Remark: If the WEBDEV administrator is closed, the email spooler is cleared: pending emails are not sent and are removed from the spooler.
If there are pending emails, and the "Disable the email spooler" option is checked, the emails will not be lost: the administrator continues to send them, but the spooler will not accept any new emails.
Caution: The asynchronous mode can only be used when starting a session on an SMTP server (EmailStartSMTPSession for sending emails or EmailStartSession). The asynchronous mode is ignored in all other cases.
Component: wd290com.dll
Minimum version required
  • Version 9
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help