Overview
Emails are sent using a File Exporter which allows you to email information about data in PhixFlow and optionally add a file as an attachment.
Email Accounts Setup
In order to send an email from PhixFlow you must setup an Email Account to send the emails from.
- In the Repository, navigate to Full Repository → Email Accounts
- If you have an account setup double click on it and the following screen will open:
- Make a note of the Login name.
- If do not have an email account that can be used to send notifications:
- Contact your IT Team to setup an account that can be used to send notifications
- Or
- If you are using a PhixFlow hosted instance contact support to set this up for you.
- Now, enter the details as detailed in Email Account.
Testing the Account
To the email account you wish to use:
- Enter your email address in the Test To: box.
- From the more menu at the top of the properties, click Test Configuration.
- You should now receive an email from the Login address setup on your Email Account. For example notifications@phixflow.com.
Sending an Email
In this example we will send an email with an attachment that contains a list of processed employees for a particular day. This data is available from the downloads section of our Learning Centre.
- Create an analysis model or open the one that will contain the required data.
- Add to the model a table which contains the data you wish to export as an attachment.
- Note in this example I have created a second table, Send Email, that is used only to send the email and will not affect the imported of data.
- From the Toolbar drag a File Exporter onto the canvas.
- Connect the Table to the File Exporter. This will be used to invoke the File Exporter.
- Connect the Table to the File Exporter a second time. This will be used later to count the records.
- In the pipe properties which open, 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.
- File Name, is the name the exported file will be given, it is an expression field. The file extension should match the type of data being exported.
- For simple file names simply encapsulate the desired text in quotes, such as
"Employees.xlsx".
- For dynamic file names use an expression to generate a name, such as:
"Employees_"+today()+".xlsx"
, which will provide the file name Employees_20220831.xlsx. The expression must return a string.
- For simple file names simply encapsulate the desired text in quotes, such as
- 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 is also 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 Stats.csv 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. This We will count the records using the recs pipe. To do this to be:
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 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 InputMultiplier 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. For example:
"info@phixflow.com"
.
- TO Expression, This is an expression field. For example:
- Save you changes.
- Basic Settings
- Save you analysis model.
- Run analysis on the table set to call the file exporter. For example, in our example this is Send Email.
Here is an example screenshot of this configuration:
Testing the Results
- Run analysis on the table that drives the File Exporter that will send 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 depending on the size of your screen.
- 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.
- 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:
- Create an Analysis Model or open one that contains the required tables.
- From the Toolbar drag a File Exporter onto the canvas.
- Connect the Table which contains the desired data to the File Exporter. This will be used to invoke 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.
- In the pipe properties which open, set:
- The setup is similar to our previous example, 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. In our example we send a personalised message to the user using their first name, and a link to login to PhixFlow:
- 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. For example, in our example this is Send Email Requests.
Send Emails with 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.