06. Push and Pull Email [9:15]

Description: This video demonstrates sending e-mail from FileMaker Pro to Microsoft Outlook.   It also demonstrates pulling e-mail from Outlook into FileMaker.

YouTube Preview Image

Transcript:

Hi, in this video we’re going to take a look at working with Outlook e-mail. Open up the beginner demo. Register the plug-in. Authenticate and let’s first take a look at “pushing mail” from FileMaker to Outlook. We have the “To”, the “CC” and the “BCC” for storing e-mail addresses,  subject, body and a place for attachment. So if I click “send e-mail”, that will send an e-mail to Outlook. Let’s take a look at that.  So here we have – you can see that it populated the to, the subject and the body of the e-mail. You can create a CC and let’s add an attachment. And send the e-mail again-take a look at Outlook. This time we have an e-mail that includes an attachment and a CC.

 

1:29 So sending e-mail is fairly simple. The method that we use is a single command. So this script simply does the plug-in checker which checks for registration.  Then it calls the authenticate command.  And this is where the script is defined to send the e-mail.  So we’re using the “PCEM_SendMail” command with several parameters. The first parameter is the to, the cc, the bcc, subject and body, and finally we have the attachment path which includes both path to the attachment as well as the attachment name. We’re using the “substitute” command here to further define the path in a format that’s acceptable to the plug-in. For more information on the exact specifications of that path, refer to the documentation. The final parameter in this case is a “N” which allows you to use and send the e-mail as HTML or plain text. “N” in this case stands for plain text.

 

2:50 So a single command can send mail. And there’s more information on sending e-mail.  If you want to learn about sending HTML e-mail or Rich text e-mail you can refer to the documentation and the advanced demo where we have examples on how to do that.  In this case the attachment we’ve sent is referenced in the container field in FileMaker. So this button here simply inserts a reference to the attachment document, or in this case “attachment.rtf”.  And it uses that to identify a path. The plug-in simply needs a path and a filename in order to attach it. You can send multiple attachments as well. Again, for an example of multiple attachments you can look at the advanced demo or refer to the documentation.  So pushing e-mail has some advantages here with Outlook in that it removes the security dialog that you would normally see when you send mail from FileMaker Using the traditional mail command.

 

3:58 Pulling e-mail. When the demo opens up it first attempts to grab all the Outlook folders that you have within your e-mail environment. In this case I have deleted items, drafts, inbox, and a few subfolders within inbox, junk e-mail, outbox, and some RSS boxes. So if I want to pull e-mail from the inbox ( which is the default in this demo) I can specify my Outlook folder as the inbox and click “Pull”. Currently there are no messages in the inbox so let’s go add some. I’ve since added some e-mail to the inbox. I have test one, test two and test three as e-mails. Test three has an attachment. So click on the e-mail pull. Again we’re pulling from the inbox folder. Those three e-mails just came in.  Here’s the Outlook ID, the sent on, the received on – those are broken out into date and times.

 

5:06 When you get the information for sent on, it’s actually coming to you as a timestamp. We’ve just added a calculation field to break out the date and time separately just to make it distinct. The to, the cc, the bcc, the from, subject, body, header. There are additional fields you can pull such as categories that are explained in the advanced demo or in the documentation. So let’s take a look at how this e-mail is pulled. So here’s the script that does that. We first show all the records in FileMaker and delete all the records. So that way, if we had any e-mails prior to clicking the button, they’d be deleted. Then we performed the authenticate. Then the “open folder”. This tells Outlook which folder we’d like to look at. Here I’m specifying a global field of FileMaker which is set to “/inbox” which you saw in the preview screen.

 

6:15 Then we get the record count – this tells us how many e-mails we have in the inbox. Then we create a new FileMaker record and we tell Outlook to position itself on the first record. So that’s the “PCEM_GetFirstRecord” command. Then we create a loop. This will allow us to get multiple records. And let’s skip over the exit loop for a second and just look at the fields we’re pulling. In the “to” field in FileMaker we’re getting data from Outlook’s “to” field. Let’s take a closer look at that. PCEM_GetFieldData specified “to” – that’s the Outlook field name. For a complete list of field names you can refer to the “fields and functions” PDF document that’s part of the download package. So we grab the “to”, the “cc”, the “bcc”, populate all these fields in FileMaker from data from Outlook, and so forth.

 

7:14 Then towards the end, we determine if the count we received up here when we learned how many records there were in the inbox – if that count matches the current found count in FileMaker, we exit the loop. Up here we talked about another exit loop. So on this exit loop we’re exiting if the Outlook ID returns the word “end”. We would receive that information down here. When we call to get next record and we’re at the last record already, it will return the word “end” when you’ve reached the last record in Outlook. So, we exit the loop here if that happens. Or we exit the loop if the Outlook ID is less than zero.

 

8:00 So that’s how we pull multiple records regarding e-mail. To get more information on pulling attachments or even multiple attachments, you can refer to the advanced demo or the documentation.  Finally let’s take a look at this record in Outlook. We can view the record directly by clicking the “view” button here in FileMaker. And that script looks like this. We call the “open record” command (“PCEM_OpenRecord) and we enter the Outlook ID we received when we pulled the e-mail originally. So that tells Outlook which record to open.

 

8:55 And then to display the record, we use ”PCEM_Display”.  And that will bring the record to the foreground -it will actually open up the email in detail view. Thank you for watching.

Tags: , , , , ,