The EmailLibrary collection provides user code methods that allow you to send emails directly from within your test run. This library replicates most of the functionality of the EmailModule. Unlike this module, the method in this library allows you to attach a file to the email.
EmailLibrary methods
To use these methods, add them to your recording module. For more information, see Using the User Code Library.
SendEmail
This method sends an email message using the SMTP server settings and information you provide.
Arguments:
- String subject: Defines the subject line of the email.
- String body: Specifies the main text content of the message.
- String to: Lists the recipient email addresses (separate multiple addresses with a comma or semicolon).
- String from: Defines the sender's email address.
- String[] attachments: Paths of files to attach.
- String serverHostname: Sets the hostname or IP address of your SMTP server.
- int serverPort: Specifies the port number for the SMTP server (for example, 25 or 587).
- bool useSSL: Enables SSL/TLS encryption when set to true.
- String username: The username for SMTP server authentication.
- String password: The password for SMTP server authentication.
The method returns a boolean value (true or false) that corresponds to whether the email was sent successfully or not. Like other return values, you can pass it on to other actions or modules.