This page is for application designers who want to send notifications via email.
Overview
To send email notifications to application users, configure a File Exporter. This allows you to email information about data in PhixFlow and optionally to add a file as an attachment.
Email Accounts Setup
In order to send an emails, PhixFlow must have an Email Account from which to send emails. Email accounts are configured for the whole PhixFlow instance rather than in an application. This means you need administrator privileges to create an account.
Step 1 Create an email account
If there is no PhixFlow email account, ask your PhixFlow administrator to create one. If you are using a PhixFlow hosted instance, email support@phixflow.com. Also ask for permission to edit the account.
Step 2 Configure the email account
- In the repository, go to Full Repository → Email Accounts.
- Double-click the account name to open its properties.
- Make a note of the Login name as you will need to know it when testing.
- Configure the email account as required; see Email Account properties for details of the options. Set
- Outbound: tick
- Enabled: tick
- Save your changes.
Step 3 Test the email account
- Reopen the email account.
- In Test To enter your email address.
If the Test To option is not visible, make sure Outbound is ticked. - In the properties toolbar, click More Options and select Test Configuration.
- PhixFlow sends an email to the address specified in Test to.
- Check your email. There should be an email address from the emal account's Login address, for example
notifications@phixflow.com
.
Sending an Email
You may want to add an attachment to an email.
In this example, we will send an email with an attachment that contains a list of processed employees for a particular day.
You can download the example data from the PhixFlow Learning Centre.
Step 1 Create an analysis model to generate the attachment
- Create an analysis model or open one that contains the required data; see Analysis Models for Batch Processing Data and Exporting to a File.
- Add the table that contains the data you want to export.
- Add a second table. In the example above this is called Send Email.
This separates the data from generating the email, which gives you more control over the different tasks. - From the analysis model toolbar drag in a File Exporter onto the canvas.
- Connect the file exporter to the Employees table
- first. This will be used to run the File Exporter later.
- Connect the Table to the File Exporter a second time. This will be used to count the records later.
- The example below has a file importer which loads data into the table Employees. Once the data is loaded, set the table to Static.
- In the pipe properties which open for the second connection, set:
- Name, recs.
- Type, select Look-up.
- Save your changes.
- Your setup should look lie the following:
- Click on the File Exporter to open its properties:
- Basic Settings
- Name, indicative of the email being sent.
- Enabled, ticked. This enables the file to be exported and email to be sent. Typically this is only unticked during testing to avoid generating lots of data and emails.
- File Name, is the name given to the exported file, it is an expression field. See Expressions and PhixScripts. The file extension should match the type of data being exported.
- For simple file names, encapsulate the desired text in quotes, for example:
"Employees.xlsx".
- For dynamic file names, use an expression to generate a name, for example:
"Employees_"+today()+".xlsx"
, which will provide the file name Employees_20220831.xlsx. The expression must return a string.
- For simple file names, encapsulate the desired text in quotes, for example:
- Output Directory, determines where the file will be placed inside the export directory on the server, unless Ignore Base Directory is ticked. More information on the settings can be found in File Exporter. This field is an expression.
- Export File as, the desired output file type. For this example we are using Excel Spreadsheet.
- Overwrite existing file can be ticked if you always want to overwrite files that have the same name. For example, if you only require one Employees.xlsx file on the server at any one time.
- Header is ticked so the output file has column headers.
- Input Multiplier
- Input Multiplier, The input multiplier expression should evaluate to a list of one or more values. For each value in the list, the internal variable _inputMultiplier will be set to that value. We will count the records in the recs pipe. To do this set the input multiplier to:
if(countElements(recs) > 0, countElements(recs), 0)
- Send by Email
- Email From, this should be the email address set in Email Accounts → Email Account → Login. For example,
notifications@phixflow.com
- Subject Expression, this is an expression field. For example,
"RE: Employee Records "+today()
- Attach File, Ticked if you want to attach the records to the email. Leave this unticked if you do not want to send the attachment with the email.
- Message Expression, this is an expression field. For example, the following incorporates the value from the Input Multiplier to create a message that tells the recipient how many records were processed:
"We have processed "+_inputMultiplier.1+" employee records today."
.
- Email From, this should be the email address set in Email Accounts → Email Account → Login. For example,
- Recipient Expressions
- TO Expression, This is an expression field. It must contain the email addresses of the recipients of this information. For example:
"info@phixflow.com"
.
- TO Expression, This is an expression field. It must contain the email addresses of the recipients of this information. For example:
- Save you changes.
- Basic Settings
- Save you analysis model.
- Run analysis on the table that is set to call the file exporter to test it works. For example, in our example this table is Send Email.
Here is an example screenshot of this configuration:
Set up the Actionflow
- From the application home screen click on Screens.
- Open the screen that you want send the email from or create a new screen to send the email. See Designing Screens.
- Add a Button to the screen that will be used to call the email. These are available from the palette.
- Right-click on the button and select Add Actionflow.
- Give the actionflow a meaningful name, for example:
Send Email Notification
. - In the actoinflow that opens, click on Connection, and select On Click.
- From the toolbar drag an Analysis Task onto the Canvas.
- Provide a meaningful name.
- From the table section click Table, from the pane that opens drag the Table we created earlier to call the file exporter into the Analysis Task.
- Save your changes.
- Connect the On Click input to the Analysis Task by dragging a line between the two. See Wiring Actionflows.
- Save your changes.
- The button is now set to run the Analysis Task that will result in the email being sent.
Testing the Results
- Run analysis on the table that drives the file exporter that sends the email.
- Open the System Console
- In the Completed Tasks section click on the Run Analysis Task you ran in the previous step.
- In the Messages for this completed task click on the Emails tab.
- If it is not visible you may need to click on the more menu to see the option.
- In the Status column, one of the following common statuses will be set:
- Ready, the email is produced
- Incomplete, PhixFlow is trying to send the email.
- Sent, the email has been successfully sent.
- It can take a few minutes for an email to be sent and sometimes longer if the attached file is large.
- If the status stays as Incomplete, test your Email Account setup above is working correctly.
- The Files tab shows any files produced as part of this completed task.
- This is useful to see if the exporter ran but the email portion has failed.
- If you email has not been received check the log for any errors. It is also worth while checking your Junk folder in your emails.
Sending an Email Incorporating Table Data
Following the example above we will now setup an example where an email will be sent to any employee that has a missing telephone number. To achieve this we will perform a lookup that only returns the employee records without a telephone number, however you can easily amend this setup to suit your needs:
- Create an Analysis Model or open one that contains the required table.
- From the Toolbar drag a File Exporter onto the canvas.
- Connect the Table which contains the desired data to the File Exporter.
- Connect the Table which contains the desired data to the File Exporter, a second time.
- In the pipe properties which open, set:
- Name,
recs
. - Type, select Look-up.
- Filter, Set the filter criteria for the lookup, we only want to return the records we wish to interact with. In this example only the records which have a missing telephone number, as illustrated here:
- Save your changes.
- Name,
- In the pipe properties which open, set:
- The setup is similar to our previous example but with the addition of a filter on the lookup pipe, as illustrated here:
- The setup for the File Exporteris the same as the Sending an Email example above, with the following changes:
- We do not want users to receive a file, make sure Attach File is
unticked
. - Input Multiplier, The input multiplier expression should evaluate to a list of records we want to interact with. We set PhixFlow to use the records from the lookup pipe. In our example the lookup is called mtn so we set the _inputMultiplier to:
mtn
- Send HTML, tick this as we want to send our contacts a HTML email.
- Message Expression, With Send HTML ticked the message is treated as html which allows us to use HTML markup in our message. In our example we send a personalised message to the user with their first name, and a link to login to PhixFlow. See Expressions and PhixScripts:
- PhixFlow HTML Message
do( "<p>Hi " + mtn.FirstName + ",</p>"+ "<p>Please login to PhixFlow and update your number.</p>"+ "<a href='https://services.phixflow.com/themes/start.html?application=Anthony'>PhixFlow Login</a>" )
Save Your changes.
- We do not want users to receive a file, make sure Attach File is
Run analysis on the table set to call the file exporter to test it works. For example, in our example this is Send Email Requests.
- We can now connect the table to an button and actionflow as outlined in the Sending an Email example above.
Send Emails with Excel Template
See Excel Template.
More Information
For more information on the file exporter and a full list of email options see, File Exporter.
For more information on expressions and using them in expression fields see, Expressions and PhixScripts.