Home Docs Changelog Download Pricing Service Center Contact

How to dynamically set the recipient of an email?
How can I dynamically set the recipient of a task during runtime? For instance, reading the email address from a table and having the system send the report generated by the task to that email address.

Yes. You can utilize the variable feature of SQLMessenger to dynamically set the recipient's email address for the task.

Assuming the recipient's email address is stored in the "mail_addr" column of the "t_admin" table in your database, you can configure the task to dynamically determine the recipient's email address during its execution as follows:

Step1: Create a variable in the task configuration to read the variable value from the 'mail_addr' column of 't_admin'

Step2: When setting the task recipient, click the "From A Variable" button and select the variable created in the previous step

After deploying the task configuration, the system will read the data from the 'mail_addr' column in the 't_admin' table as the recipient address when the task is executed.

Note: The system will add all addresses retrieved by the SQL statement of the variable to the recipient list. Therefore, when configuring the SQL statements of the variable, please ensure to use query conditions in the WHERE clause to limit the search results. For example:

SELECT mail_addr
FROM   t_admin
WHERE  employee_name = 'Andy' --Query only the email address of a specific employee
; 

Using Variables in Tasks, Setting Recipients for Tasks

Last updated on June 28, 2024

Cookie Settings

We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies in accordance with our Cookie Policy.

You can change your preferences at any time by clicking on "Cookie Settings" in the website footer.

Cookie Preferences

Manage your cookie preferences. You can enable or disable different types of cookies below. Necessary cookies cannot be disabled as they are required for the website to function properly.

Necessary Cookies

Always active

These cookies are essential for the website to function and cannot be switched off. They are usually only set in response to actions made by you such as setting your privacy preferences, logging in or filling in forms.

Preferences Cookies

Makes the site easier to use

These cookies allow the website to remember choices you make and provide enhanced, more personal features.

Analytics Cookies

Helps us improve our website

These cookies help us understand how visitors interact with our website, which helps us improve our products and services.

Marketing Cookies

Used to track visitors across websites

These cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging.