ajSendEmail function
Description
The ajSendEmail function sends an email to recipients with a given subject, message, and attachments.
Syntax
ajSendEmail(host, port, sender_address, to_address, cc_address, bcc_address, subject, message, [html_mail], [attachment_path], [run_condition], [run_by_function_point_only])
Argument Name** | Description |
---|---|
host (required) | Specify the IP address or FQDN of the SMTP server. |
port (required) | Specify the listening port of the email service of the SMTP server. |
sender_address (required) | Specify FROM email address. |
to_address (required) | Specify TO email address from a range of cells. The range of cells can span across multiple rows and columns. Each cell should contain one email address. |
cc_address (required) | Specify CC email address from a range of cells. The range of cells can span across multiple rows and columns. Each cell should contain one email address. |
bcc_address (required) | Specify the BCC email address from a range of cells. The range of cells can span across multiple rows and columns. Each cell should contain one email address. |
subject (required) | Specify the subject of the email. |
message (required) | Specify the content of the email from a range of cells. The range of cells can span across multiple rows and columns. Each row represents a broken line and all the columns will be concatenated. |
html_mail (optional) | If it equals FALSE, the function will process the Body as plain text. If it equals TRUE, the function will process the Body as HTML formatted. If you do not specify anything, the default value will always be FALSE. |
attachment_path (optional) | Specify the attachment file paths of the email from a range of cells. The range of cells can span across multiple rows and columns. Each cell contains one file path. If you do not specify anything, the default value will always be an empty string (“”), which is no attachment. |
run_condition (optional) | The function will run when the value is TRUE. Otherwise will not run. If you do not specify anything, the default value will always be TRUE. |
run_by_function_point_only (optional) | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Run Function Point. If it equals TRUE, the function can be executed with Run Function Point (AlchemyJ toolbar \ Run Function Point) only. If you do not specify anything, the default value will always be TRUE. |
Example
This example sends an HTML email to an email address.
The result is TRUE which indicates the email has been sent out successfully. However, it does not necessarily mean the recipient can receive or has received the email. Whether a recipient receives the email depends on how the mail server handles the email. That is beyond the reach of this function.
It will return #VALUE! when there is an error in the usage of the function.
As Html_mail is TRUE and an email body is in HTML format, the mail client displays the content with HTML formatting.