PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Managing emails in asynchronous mode
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Returns the status of an email sent via an SMTP session started in asynchronous mode.
Versions 23 and later
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
New in version 23
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
Example
// Send an email via the SMTP protocol
IF EmailStartSession(USER, PASSWORD, "pop3.ifrance.fr", ...
"smtp.ifrance.fr", 110, 25, True) = True THEN
UserName = USER
ELSE
UserName = ""
Error("Unable to establish the connection")
END

// Initialize the email structure
Email.Recipient = "support@pcsoft.fr"
Email.Sender = "Tartampion@box.net.eu"
Email.Message = "Auto Email Test"
Email.NbRecipient = 1

// Send the email
IF EmailSendMessage(UserName) = False THEN
Error("EMailSendMessage failed '" + ErrorInfo(errMessage) + "'")
ELSE
Info("EmailSendMessage was successful")
END
...
// 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))
END
Syntax
<Result> = EmailStatus(<Email Identifier>)
<Result>: Constant
Outgoing status of the specified email:
emailSentThe email was sent.
emailPendingThe email is waiting to be sent. It is in the spooler.
emailErrorAn error occurred. The error details are returned by ErrorInfo(errMessage).
<Email Identifier>: Integer
Identifier of the email (Email.MailIdentifier variable or ..ID property of the Email variable initialized when the email was sent by EmailSend and EmailSendMessage).
Remarks

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 the outgoing emails will be transmitted to a "spooler". The emails are queued up before they are sent.
The execution of Email functions do not lock the rest of your program anymore. EmailStatus is used to find out the status of an email.
Note: If the WEBDEV administrator is closed, the email spooler is cleared: the pending emails are not sent and they are removed form the spooler.
If "Disable the email spooler" is checked while emails are still found in the spooler, these emails will not be lost: the administrator keeps sending them but no new email is accepted by the spooler.
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 the other cases.
Components
WEBDEV - Server code wd230com.dll
Linux wd230com.so
Minimum required version
  • Version 9
Comments
Click [Add] to post a comment