Tuto WINDEV 25
246 Part 4: Full application with data This code is using an advanced emailSMTPSession variable. The different properties of this variable are used to define the characteristics of SMTP session. Then, EmailStartSession associated with this variable is used to start the session. • WLanguage code for preparing the email: MyMessage is Email MyMessage..Sender = EDT_Sender MyMessage..Subject = EDT_Subject MyMessage..HTML = EDT_HTML_Text MyMessage..Message = HTMLToText(EDT_HTML_Text) // Adds a recipient Add(MyMessage..Recipient,... COMBO_Recipient..DisplayedValue) // Adds the attachment if necessary IF EDT_File <> "" THEN EmailLoadAttachment(MyMessage, EDT_File) END This code is using an Email variable. The different properties of this variable are used to define the characteristics of email to send. This code associates the content of different window controls to the properties of Email variable. • WLanguage code for sending the email: // Send the email IF EmailSendMessage(MySession, MyMessage) = False THEN Error("Message not sent.", ErrorInfo()) ELSE // Message sent ToastDisplay("Message sent", toastShort, ... vaMiddle, haCenter) END The email is sent by EmailSendMessage . All you have to do is pass in parameter the variable containing the characteristics of SMTP session and the variable containing the characteristics of email to send. If the email is sent, a Toast message is displayed, indicating that the email was sent. A Toast message corresponds to a furtive message. • WLanguage code for closing the SMTP session: // Closes the SMTP session EmailCloseSession(MySession) This code closes the session with EmailCloseSession . ▶ Save the window and its code ( or Ctrl + S).
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==