ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Rich Text Area control
  • Example: Sending a custom email
EmailSend (Example)
Example: Sending a custom email
The following code is used to send an email whose content is entirely customized. The email variables are used to enter the main characteristics of the email.
The session is closed when the email is sent.
// Create the message
MessageContent is string
MessageContent = "Return-Path: <%1>" + CR + ...
"From: ""%2"" <%1>" + CR + ...
"To: <%3>" + CR + ...
"Subject: %4" + CR + ...
"MIME-Version: 1.0" + CR + ...
"Content-Type: text/plain;" + CR + ...
"Charset=""us-ascii""" + CR + ...
"Content-Transfer-Encoding: 7bit" + CR + CR + "%5" + CR
 
// Start an SMTP session
EmailStartSMTPSession("SMTPSession", "HL")
IF ErrorOccurred = True THEN
Error(ErrorInfo(errSummary))
RETURN
END
 
// Reset the Email variables to zero
EmailReset()
 
// Sender of the message
Email.Sender = "sender@sender.com"
Email.SenderAddress = "M. Sender"
 
// Recipients of the message
Email.NbRecipient = 1
Email.Recipient[1] = "recipient@recipient.com"
 
// Subject and content of the message
Email.Subject = "Email subject"
Email.Message = "Email body"
IF fSaveText("EmailContent.txt", ...
StringBuild(MessageContent, Email.Sender, Email.SenderAddress, ...
Email.Recipient[1], Email.Subject, Email.Message)) = False THEN
Error(ErrorInfo())
ELSE
EmailSend("SMTPSession", "EmailContent.txt")
IF ErrorOccurred = True THEN
Error(ErrorInfo())
END
END
 
// Close the SMTP session
EmailCloseSession("SMTPSession")
fDelete("EmailContent.txt")
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help