Product Logo

POP3it Pro

Email downloading made easy.

Integrate POP3it Pro Into a Database

Introduction

This example walks you through building POP3it Pro into a database. For this example you can either use the Customers example database (available on the “Download Example File” section) or your own database. The Customers download contains two databases. The database named “Customers” can be used as you follow through this example. The “Customers Completed” database shows an example of what the database structure could look like after you finish following this example.

Customers example database

Download Example File

FileMaker 7–11 Example

FileMaker 12 Example

Example Explanation

To begin, you will need to create a field in an existing table. If you are using the Customers example database, the existing table is named Customers.

  1. Open the Define Database dialog by clicking File, "Manage" or "Define", Database, and click on the Fields tab.
  2. In the "Field Name" field type "Results", select a Type of "Text", and click the Create button.
  3. Click the "Options" button, go to the "Storage" tab, and select the check box "Use global storage".
  4. Click OK on this dialog, and then click OK again on the Define Database window.
  5. Click on the Scripts menu and then select ScriptMaker/Manage Scripts.
  6. Click New to create a new script and give it a name of "Receive Email".
  7. On the left hand side, scroll down the list until you find Set Field and double-click on it to add it to your script.
  8. Click the Specify Target field "Specify" button, which will bring up a dialog titled Specify Field.
  9. From the drop down menu, select the table that the "Results" field was created in (this is the Customers table in the example), and then select the "Results" field and then click OK.
  10. Now click the Calculated result "Specify" button. A new window will open with a title of Specify Calculation.
  11. In the right hand top corner is a drop down menu with the word "View:" beside it. Click the menu and scroll to the bottom and select "External Functions".
  12. In the pane below the drop down window will be the functions for all the plug-ins you have installed.
  13. Scroll down this list until you find POP3it Pro, and then locate the "POP3it_CheckAccount" function.
  14. Double-click on it to add the function to your calculation.

Your calculation should now look like this:

POP3it_CheckAccount{( AccountName {; ShowStatus } )}
/* AccountName = The Account to Check. If you want to check All defined Accounts, specify “All”. If you want to choose which Accounts to check from a Dialog, specify “Dialog”. If you want to check more than one Account, separate the Account Names with a Return or the Paragraph Mark. [Default is “All”.] ShowStatus = If True, and the Status Window is not already open, the Status Window will open and close while checking the Account. [Default is True.] */

For this example, we are going to make the plug-in download email from all Accounts that are specified, so remove the parameters ( “{( AccountName {; ShowStatus } )}”) from the function syntax. If you wanted to only download email from a specific account, you would specify the name of that Account in the “AccountName” parameter. Notice the {} curly brackets in the function syntax. This means the parameters inside the brackets are optional. Since we are not going to specify an Account name, we will just remove the parameters. Your function should now look like this:

POP3it_CheckAccount
/* AccountName = The Account to Check. If you want to check All defined Accounts, specify “All”. If you want to choose which Accounts to check from a Dialog, specify “Dialog”. If you want to check more than one Account, separate the Account Names with a Return or the Paragraph Mark. [Default is “All”.] ShowStatus = If True, and the Status Window is not already open, the Status Window will open and close while checking the Account. [Default is True.] */

If the text inside the /* */ tags bother you, it can also be removed as this is just a human readable comment or “help” section and FileMaker will ignore it. It will not hurt anything if this data is left, however. Click the OK button to close the “Specify Calculation” window, and then click OK again to close the Edit Script window. Finally, click OK on the Define Scripts window.

Click the View menu, Go To Layout, and select a layout that shows records from the table we added the “Results” field to (this is the Customers layout in the example database). Enter Layout mode by clicking the View menu, and then Layout Mode. From the Insert menu select Button, scroll down the list of steps and select Set Field. Click the “Specify target Field” Specify button. Select the table that the “Results” field was created in (this is the Customers table in the example), select the “Results” field, and then click OK. Click the “Calculated result” Specify button to open the Specify Calculation window. As before, in the right hand top corner is a drop down menu with the word “View:” beside it. Click the menu and scroll to the bottom and select External Functions. Scroll down this list until you find POP3it Pro, and then locate the POP3it_ConfigureAccount function. Double-click on it to add the function to your calculation. Your calculation should now look like this

POP3it_ConfigureAccount{( AccountName )}
/* AccountName = The Account to Configure. [If blank, you will be able to select the Account from a list.] */

Remove the parameter (“{( AccountName )}”) from the function because no Accounts have been created and we want to make a new one. Your function should look like:

POP3it_ConfigureAccount
/* AccountName = The Account to Configure. [If blank, you will be able to select the Account from a list.] */

Click the OK button on the Specify Calculation window and then click OK again on the Button Setup window. Your cursor will now be on the button object, so give it a name of “Accounts”. Place the Accounts button wherever you like on your layout. Now create another button from the Insert, Button menu. For this button, select “Perform Script” from the list, click the “Specify” button and select the “Receive Email” script. Click OK to close the “Specify Script Options” window, and then click OK again to close the “Button Setup” window. Again, your cursor will be in the button object, so give it a name of “Receive Email”, and then place the button on your layout to your liking. From the Insert Menu, select Field, from the drop down menu select the table that the “Results” field was created in (this is the Customers table in the example), and then select the “Results” field and click OK. If the plug-in has an error, this field will contain that error message. Click the View menu, select Browse Mode, and if prompted to save changes click the Save button.

Your database is almost ready to check email, but first you must enter your mail server settings. To do so, click the “Accounts” button you created earlier, which will open the Account Configuration Dialog. In the top right hand corner is a + button, click that to add a new account, give it a name and click OK. On the Connection tab enter your POP3 Host (e.g. mail.domain.com), and the authentication type can be left as Auto unless you know the specific type. Enter your Username and password for your email address. Note, the username may be your full email address (e.g. user@domain.com) or it may only be your username (user) without the “@domain.com”. This is different for all email servers so if you are unsure, please contact your mail server administrator. If your mail server requires SSL, select either “After Connect” or “Before Connect” depending on your mail server. You can also change the port to connect to your mail server (default is 110) and the connection timeout value. When you finish editing your settings, click the Save button and then the Close button.

The database is now ready to download email so click the “Receive Email” button you created. The plug-in will now try to download email, but first it must create a new table for the email and attachments. Your “Results” field will give you an error saying this. Click the “Receive Email” again to download email. Once the plug-in is finished downloading email go to the View menu, and select Layout Mode. From the Layouts menu select New Layout/Report which will open FileMaker’s New Layout/Report wizard. Click the “Show records from:” drop down menu and select “POP3it_Messages”. In the “Layout Name:” field type something like “Email”, and click Next. The next window allows you to specify what fields you want on the layout, and for this example we will view all of the fields so click “Move All” (alternatively you can select only the ones you want to view). Click the Next button. Select from the list the theme you would like to use (for the example we used “Default”), and click Finish. From the View menu select “Browse Mode”, and click “Save” if prompted. You are now looking at the “Email” layout which will show all of your email. You may want to go into Layout Mode again to arrange the fields and make the fields bigger to fit your needs.

To view the attachments for your email, you will need to create a relationship between the POP3it_Messages table and the POP3it_Attachments table. To do so, go to File, Define, Database, and click the Relationships tab. In the POP3it_Messages table select the “POP3it_UIDL” field and drag to the “POP3it_UIDL” field in the “POP3it_Attachments” table. There should now be a line connecting the two tables with an equal sign in the middle of the line. Click the OK button to close the Define Database window. On your Email layout, go to the View menu and click Layout Mode. From the Insert menu select Portal which will put a portal object on your layout. In the “Portal Setup” window click the “Show related records from” drop down menu, select “POP3it_Attachments”, and then click OK. In the “Add Fields to Portal” window, double-click the POP3it_FileName field to add it to the “Included fields” pane, and then click OK. From the View menu select Browse Mode and click Save if prompted. When browsing through your email records if an email has attachments, they will appear in the portal object you created. You could also create a layout using the POP3it_Attachments table, but since you have a portal on your Email layout that may not be necessary depending on your needs.

Your database now has the ability to download email with the help of POP3it Pro. This is only a brief overview of the functionality of the plug-in and you can view more possibilities in the other Examples.