ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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, "pop3.gmail.com", ...
"smtp.gmail.com") = True THEN
NomUser = USER
ELSE
  NomUser = ""
  Error("Impossible d'établir la connexion")
END
// Initialise les composantes du mail
Email.Sender = "<user@pcsoft.fr>" // 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
Error()
END
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] = "pcsoft@pcsoft.fr"
Email.NbAttach = 0
Email.Message = ""
// Envoi du message à MS Exchange
EmailSendMessage(IDEmail)
...
EmailUpdate(IDEmail)
...
EmailCloseSession(IDEmail)
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 = "smtp.gmail.com"
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] = "pcsoft@pcsoft.fr"
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))
END
ELSE
Error("Impossible d'établir la connexion", ErrorInfo(errMessage))
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/29/2023

Send a report | Local help