ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / Managing emails
  • Asynchronous mode
  • Progress Bar
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Sends an email:
  • by using the SMTP protocol: the email is directly sent to the server. The email is actually sent when disconnecting from the SMTP server (i.e. when the session is closed).
  • WINDEVWEBDEV - Server code via the MS Exchange client: the email is placed in the outbox of MS Exchange. To actually send the email, use EmailUpdate.
  • WINDEVWEBDEV - Server code via the Lotus Notes software: the email is placed in the outbox of the messaging software. The email is automatically sent by the spooler of Domino.
    Caution: Lotus Notes must be installed in connected mode (and not in local mode).
  • WINDEVWEBDEV - Server code via the Outlook software: the email is placed in the outbox of the messaging software. The email is actually sent from Outlook. For more details, see Accessing Outlook.
Caution: Before sending the email, you must:
Universal Windows 10 AppAndroidAndroid Widget iPhone/iPadJava In this version, the emails can be sent via the SMTP protocol only.
PHP In this version, the emails can be sent via the SMTP protocol only. Before sending this email, there is no need to start a session with EmailStartSession. To actually send the email, the SMTP server to use must be supplied to the PHP engine. It must be specified in the "SMTP =" entry of PHP.INI file.
WINDEVWEBDEV - Server codeReports and QueriesUniversal Windows 10 AppAndroidAndroid Widget iPhone/iPadUser code (UMC)Ajax Sending a message by SMTP
// Ouverture d'une session SMTP
MaSession is emailSMTPSession
MaSession.ServerAddress = "smtp.masociete.fr"
EmailStartSession(MaSession)
 
// Construction d'un email
MonMessage is Email
MonMessage.Sender = "service_commande@masociete.fr"
Add(MonMessage.Recipient, "client@societe.com")
MonMessage.Subject = SAI_SujetEmail
MonMessage.Message = SAI_TexteEmail
 
// Envoi du message
EmailSendMessage(MaSession, MonMessage)
PHP Sending a message from a PHP WEBDEV site
// Note: l'ouverture d'une session SMTP n'est pas nécessaire
 
// Construction d'un email (utilisation de la structure Email)
Email.Sender = "service_commande@masociete.fr"
Email.NbRecipient = 1
Email.Recipient[1] = "client@societe.com"
Email.Subject = SAI_SujetEmail
Email.Message = SAI_TexteEmail
 
// Envoi du message
EmailSendMessage()
Syntax

Sending an email using SMTP Hide the details

<Result> = EmailSendMessage(<Session> [, <Email> [, <Advanced options>]])
<Result>: Boolean
  • True if the message was sent to the SMTP server,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
Java If an error occurs, the content of Email.Error variable must be checked.
<Session>: Character string or emailSMTPSession variable
Identifies the user session. Corresponds to:
PHP This parameter is not available.
<Email>: Optional Email variable
Name of the Email variable corresponding to the email to be sent. If this parameter is not specified, the information contained in the Email structure is used.
JavaPHP This parameter is not available.
<Advanced options>: Optional Integer constant
Combination of following constants:
emailOptionEncodeHeaderEncodes the message headers in Quoted-Printable if necessary.
The headers of messages are not encoded by default. This constant prevents the reception of email with wrongly decoded accented characters.
emailOptionMessageIDTakes the Email.MessageID variable into account to generate the email. This option is ignored if this variable is not specified.
This option is an advanced option.
emailOptionReferenceTakes the Email.Reference variable into account to generate the email. This option is ignored if this variable is not specified.
This option is an advanced option.
PHP This parameter is not available.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax

Sending an email via MS Exchange, Lotus Notes or Outlook Hide the details

<Result> = EmailSendMessage(<Session ID> [, <Email> [, <Display> [, <Type>]]])
<Result>: Boolean
  • True if the message was placed in the outbox of MS Exchange, Lotus Notes or Outlook,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Session ID>: Integer or emailOutlookSession variable
Identifies the current email session. This parameter can be:
<Email>: Optional Email variable
Name of the Email variable corresponding to the email to be sent.
If this parameter is not specified, the information contained in the Email structure is used.
<Display>: Optional boolean
  • True to display the message in a dialog box before sending it,
  • False (by default) to display no dialog box.
This parameter is taken into account only if the email session was started by EmailStartSession, by using the MS Exchange syntax with a profile name. In the other cases, the dialog box is not displayed.
Remark: This parameter is not available for Lotus Notes.
<Type>: Optional character string
Describes the type of message to send. By default, <Type> = "IPM" (Inter Personal Message).
Remarks
WEBDEV - Server codeAjax

Asynchronous mode

If the session was started in asynchronous mode (EmailStartSession and EmailStartSMTPSession), EmailSendMessage creates an identifier for each email sent.
The email identifier is stored in the Email.MailIdentifier variable and can be used by EmailStatus to get the current status of the outgoing email (sent, in progress, etc.).
Processing the errors in asynchronous mode: EmailSendMessage returns True if the email is placed in the email spooler, False if the spooler cannot be contacted. To determine if the email was sent, use EmailStatus.
WINDEVReports and QueriesUniversal Windows 10 AppAndroidAndroid Widget iPhone/iPadUser code (UMC)

Progress Bar

To follow the sending progress, use EmailProgressBar.
Related Examples:
Sending an email in HTML format Unit examples (WINDEV): Sending an email in HTML format
[ + ] Using the WLanguage "EmailImportHTML" function.
This function is used to import an HTML file into the email structure. This allows you to easily add images into the emails.
Sending emails Unit examples (WINDEV): Sending emails
[ + ] Sending emails with WINDEV.
WD Mailshot Training (WINDEV): WD Mailshot
[ + ] This example explains how to send a mailshot with WINDEV.

This example is used to type the subject of the message, its content and its attachments.
Then, the user must select the customers to which the message will be sent.
The WLanguge EmailSendMessage() function is used to send the message to each selected customer.
Technical implementation:
An email server compatible with POP3/SMTP must necessarily be accessible from the computer on which the application is run.
WD JavaMail Training (WINDEV): WD JavaMail
[ + ] This example is a Java example used to read and send emails.
WW_CMS Complete examples (WEBDEV): WW_CMS
[ + ] This example is an example of CMS (Content Management System).
This is a site for content management, typically a site for displaying some articles.

This example is divided into 2 parts:
- An AWP part for the part that must be referenced
- A WEBDEV part for the management part

Note:
In order for some features of the example to operate (sending emails for example), the parameters must be modified in order to adapt them to your configuration.
These parameters are stored as constants defined in the code of the project.
Component: wd300com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/23/2023

Send a report | Local help