Tuto WEBDEV 25

Part 5: Let’s continue the development 219 Sending the email ▶ To create the Button control to send emails: 1. On the "Creation" pane, in the "Usual controls" group, click . 2. Click the location where you want to create the Button control (for example, at the bottom of the page). 3. Select the control and modify its caption (press Enter for example). The new caption is "Send". 4. Edit the code of this control (F2). 5.  Type the following codes in the "Click" server event: • the code for opening the connection and for starting the SMTP session: MySession is EmailSMTPSession MySession.ServerAddress = "smtpserver" // Type the address of SMTP server MySession.Name = "user_name" // Type the user name (if necessary) MySession.Password = "" // Type the password (if necessary) // Starts the SMTP session IF EmailStartSession(MySession) = False THEN ToastDisplay("Unable to connect to the SMTP server.", ... ErrorInfo()) RETURN END 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. • the code for preparing the email: Suggestion is Email Suggestion.Sender = EDT_Sender Suggestion.Subject = EDT_Subject Suggestion.HTML = EDT_HTML_Text Suggestion.Message = HTMLToText(EDT_HTML_Text) Suggestion.Recipient = "developer@mysite" 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 page controls to the properties of Email variable.

RkJQdWJsaXNoZXIy NDQ0OA==