Navigation: »No topics above this level«
Example - Receiving An Order
Updating A Database, Forwarding Confirmation To The Customer and Printing a Report
In this example we will show how to parse an email and update an 'Orders' database... then send a follow up email to the person who placed the order and print a report.
Suppose we receive automated emails from the address 'email@example.com' that contain the following:
Order received for product "Widgets Version 1"
Name = Sharlene Baker
Company = Parker Software Inc
Street = New Broad Street
ZIP = 32814
City = Orlando
Country = United States
State = Florida
Phone = 800 680 7712
Fax = 44 1782 839682
Email = firstname.lastname@example.org
The first thing we need to do is create an Account in ThinkAutomation. Click Add Account button.
Enter the Account Name. Click the Get Via Email button.
On the POP3 tab, enable the Read Emails From A POP3 Server and specify the mail server and mail account details for the POP3 account that receives the above email's. Click Save to save the Account. When you save a new Account, ThinkAutomation will ask if you want to create a new trigger now - click Yes.
Next we need to create a 'Trigger' so that ThinkAutomation can act on just the Order email's received through this account and ignore the rest.
Since the orders are always received from the same email address (email@example.com) we can enter it in the From Address entry. The Subject line also always contains the words 'Order Received' so we can enter this in the Message Contains entry.
We can now proceed to extract fields from the email message. Click the Extracted Fields button then click the Add field button. When you add your first field it is a good idea to paste a sample email text and subject into the Find & Extract helper field. As you create your extraction fields, ThinkAutomation will highlight what will be extracted in the Find & Extract helper box. For this example, paste the subject and body above into the subject & body fields of the Find & Extract Helper.
The first field we want to extract is the Product Name. This is part of the subject line. When ThinkAutomation starts to extract fields it always starts from the 1st character of the subject line before moving to the body text.
In the Name entry enter a name for the field.
The Start From Last Extract Point is enabled by default. This tells ThinkAutomation to start searching for the field from the last field position.
Since this field will only appear in the Subject line click the Check Subject Like Only option.
In the Look For entry enter 'Order received for product'. In the Then Look For entry enter " (double quote). This tells ThinkAutomation to search for 'Order received for product' AND THEN the first double quote. The field extraction will start from the next character.
Now click the Extract Data tab
Check the Until Any Of These Characters option and enter a double quote in the box.
This tells ThinkAutomation to extract the field up to the next double quote.
Click the Database Field tab
We now need to tell ThinkAutomation the Table and Field name that this field should be inserted into.
Enter 'Orders' for the Update Table Name.
Click OK to save the Field.
Click the Add Field button to add another field.
The remaining fields are on lines on their own so can extract data 'Until End Of Line'. We set the Look For to the text before the = sign, Then Look For to '=' because we don't know how many spaces are between the Look For entry and the start of the field.
Repeat for each of the remaining fields:
Now click the Trigger Actions button.
Here we add all the Actions that we want to perform once ThinkAutomation has received the message and extracted all our fields.
Click the Update A Database - Direct Action and drag it onto the Actions list.
The Update A Database Action form will be displayed:
You will see that ThinkAutomation has automatically created an SQL Insert statement using the Table and Field names specified. If we have specified multiple table names ThinkAutomation would have created separate Insert statements for each.
Click the Build button to build a connection string for any data source available on the PC. For now just enter 'Example' in the connection string and click OK.
We now want to send the customer who placed the order a confirmation email.
Select the Send Email Action and drag it onto the Actions list. The Send An Email Action form will be displayed.
In the To entry enter %Email% - this tells ThinkAutomation to replace the send to address at run time with the value of the extracted field called 'Email'. You can also drag the field from the Fields tree.
Enter the fields as above. Notice how we can use %field% replacements in any of the Action properties. These can be typed in or dragged from the Extracted Fields list.
Click OK to save the email. You can create any number of additional outgoing messages. You can also create 'scheduled emails'. These are outgoing emails that will be sent at some point in the future. You could use this to send a 'how was your order' type message.
We may also want to print the email as it arrives. Drag the Print Message Action to the Actions list.
Click the Print Extracted Fields check box.
ThinkAutomation will then print a report of fields extracted each time an order is received. Click OK to save the Action.
Your Actions list will now look like:
Click Save to save the Trigger.
The Trigger will be saved. ThinkAutomation is now ready to start receiving orders.