|
|
|
|
|
- Example: Sending a custom email
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")
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|