This content has been translated automatically.  Click here  to view the French version.
Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Rich Text Area control
  • Example: Sending an email using SMTP
  • Example: Sending an email via MS Exchange
  • Sending Email via a secure SMTP server
EmailSendMessage (Example)
Example: Sending an email using SMTP
The following code is used to send an email by using the SMTP protocol. The characteristics of SMTP protocol have been specified by EmailStartSession (address of POP3 server, address of SMTP server, etc.).
IF EmailStartSession(USER, PASSWORD, "", ...
"") = True THEN
NomUser = USER
  NomUser = ""
  Error("Impossible d'établir la connexion")
// Initialise les composantes du mail
Email.Sender = "<>" // L'expéditeur
Email.Recipient[1] = DESTINATAIRE // Le destinataire
Email.NbRecipient = 1 // Le nombre de destinataires
Email.Subject = SUJET // Le sujet
Email.Message = TEXTE // Le corps du message
Email.NbAttach = 0 // Le nombre de pièces attachées
// Envoie le mail
IF EmailSendMessage(NomUser) = False THEN
Example: Sending an email via MS Exchange
WINDEVWEBDEV - Server codeReports and QueriesWindowsUser code (UMC)Ajax The following code uses MS Exchange to send an email. A profile ("PROFILE_Example") was created in MS Exchange. For more details on how to create profiles, see EmailStartSession.
IDEmail is int
IDEmail = EmailStartSession("PROFIL_Exemple")
// Initialisation des variables
Email.NbRecipient = 1
Email.Recipient[1] = ""
Email.NbAttach = 0
Email.Message = ""
// Envoi du message à MS Exchange
Sending Email via a secure SMTP server
// Envoi d'email via un serveur SMTP Sécurisé
// Session SMTP Sécurisée
gSessionSMTP is emailSMTPSession
gSessionSMTP.ServerAddress = ""
gSessionSMTP.Name = gsUser
gSessionSMTP.Password = gsPassword
gSessionSMTP.Port = 587
gSessionSMTP.Option = emailProtocolSMTPS
// Contenu de l'email    
UnCourriel is Email
UnCourriel.SenderAddress = gsUser
UnCourriel.Recipient[1] = ""
UnCourriel.Subject = "Envoi d'un email depuis WINDEV."
UnCourriel.Message = "Envoi d'un message email depuis WINDEV."
// Envoi de l'email
IF EmailStartSession(gSessionSMTP) = True THEN
IF EmailSendMessage(gSessionSMTP, UnCourriel) = False THEN
Error("L'envoi de l'email a échoué.", ErrorInfo(errMessage))
Error("Impossible d'établir la connexion", ErrorInfo(errMessage))
Minimum version required
  • Version 9
This page is also available for…
Click [Add] to post a comment

Last update: 06/29/2023

Send a report | Local help