- Example: Sending an email using SMTP
- Example: Sending an email via MS Exchange
- Sending emails 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 UserName = USER ELSE UserName = "" Error("Unable to establish the connection") END // Initializes the email components // The sender Email.Sender = "<user@pcsoft.fr>" // The recipient Email.Recipient[1] = RECIPIENT // The number of recipients Email.NbRecipient = 1 // The subject Email.Subject = SUBJECT // The message body Email.Message = TEXT // The number of attachments Email.NbAttach = 0 // Sends the email IF EmailSendMessage(UserName) = False THEN Error() END
Example: Sending an email via MS Exchange Sending emails via a secure SMTP server
// Send emails via a secure SMTP server // Secure SMTP session gSessionSMTP is emailSMTPSession gSessionSMTP.ServerAddress = "smtp.gmail.com" gSessionSMTP.Name = gsUser gSessionSMTP.Password = gsPassword gSessionSMTP.Port = 587 gSessionSMTP.Option = emailOptionSecuredTLS // Email content AnEmail is Email AnEmail.SenderAddress = gsUser AnEmail.Recipient[1] = "pcsoft@windev.com" AnEmail.Subject = "Sending an email from WINDEV." AnEmail.Message = "Sending an email from WINDEV." // Send the email IF EmailStartSession(gSessionSMTP) = True THEN IF EmailSendMessage(gSessionSMTP, AnEmail) = False THEN Error("Failure sending the email.", ErrorInfo(errMessage)) END ELSE Error("Unable to establish the connection", ErrorInfo(errMessage)) END
This page is also available for…
|
|
|
|