Author Topic: Drag and Drop email & attachment from outlook directly  (Read 3991 times)

FM_new_dev

  • Member
  • *
  • Posts: 3
Drag and Drop email & attachment from outlook directly
« on: January 28, 2016, 06:29:06 PM »
G'day Guys,
I am a newbie to FileMaker development and ran into the problem of adding attachments to a container feld by direct dragging and dropping from Outlook.
Outlook Manipulator has already been purchased but not integrated yet. Any guidance is really appreciated.

Using FileMaker Pro Advance v 14, Windows 7, Outlook 2013, outlook manipulator v7.0

Thanks

Joshua Palmer

  • Joshua Palmer
  • Global Moderator
  • Member
  • *****
  • Posts: 2
Re: Drag and Drop email & attachment from outlook directly
« Reply #1 on: January 29, 2016, 11:28:02 AM »
Hi,

Welcome to the FileMaker development world,

I recommend opening the Outlook Manipulator Advanced Demo file, included in the Outlook Manip. download and running the script debugger. In the Manage Scripts, is a script titled "Extract Mail Records" which has a commented section for determining if there are attachments. The section where it pulls the attachment demonstrates how to insert the attachment into a container file from script. To simplify the steps, the procedure would be:

1. get the count to determine if there are attachments
2. for each attachment
    a. get the attachment name
    b. insert the attachment using the FM Script step "Insert File[]" using the attachment name, and the desired container field.

The rest of the script steps in that script are for housekeeping, and generally to make the process smoother.

The development guide that explains the plugin's capabilities can be found here:
http://www.productivecomputing.com/docs/docs_library/Outlook_Manipulator/Developers_Guide_Outlook_Manipulator.pdf

and the functions guide for the available functions can be found here:
http://www.productivecomputing.com/docs/docs_library/Outlook_Manipulator/Functions_Guide_Outlook_Manipulator.pdf

You could also consult with us by opening a Paid Support ticket here:
http://www.productivecomputing.com/data/Support_Products.pdf

Bernard De Jonghe

  • Member
  • *
  • Posts: 17
Re: Drag and Drop email & attachment from outlook directly
« Reply #2 on: February 01, 2016, 01:30:34 AM »
Generaly spoken it is not possible to drag end drop messages and attachments directly from Outlook into filemaker.  One must drag and drop to the Desktop.  Drag and drop from the Desktop to Filemaker however works.  So it ends up in a two step process, that every one would like to avoid. Would be a nice feature for Filemaker Inc to develop. ;)

The solution is indeed to use the Insert Field script step to bring messages and attachments in a container field.
What I do is syncing the mails and their attachments with Filemaker.  During the syncing I use the PCEM_SaveRecordAsMsg function to store the message in its entirety to a mail repository on the server.
The next step is then the Insert File script step to import the message.msg file into a container field (external storage).
One detail: to enforce an absolutely unique naming of the file in the mail repository, I add a Timestamp string in front of the message name.  This has the additional advandage that the mails can be sorted in chronological order.

And then I do the same with the attachments, again using the PCEM_SaveAttachment function.  I save the attachments in another folder on the server called the Attachment Repository.  And again I use the Insert File script step to import the attachments in a container field (external storage).  And again, I use the Timestamp to ensure unique filenames.

So the filenames look for example like this:
20160131132516 - sales figures.pdf
I'm in Europe, so the Timestamp means "31 january 2016,  13:25:16"
I generate the time stamp by calculation from the receiving date coming from Outlook.

One last thing to to:
If you save a message using the PCEM_SaveRecordAsMessage function, usualy the subject of the message is taken a message filename.  But there is a danger to this: in many cases the subject of a message contains characters that are not allowed for filenames.  A typical example is the colon " : "
If this case the save operation will not perform correctly.  So what I do is the following:
Directly under my Subject field in the Mail table, I create a calculated version of the Subject field, and the calculation I perform is just substituting all forbidden characters by a space.  Doing so I produce a filename that is in accordance with the filenaming rules of Microsoft Windows. 

Hope this helps.
Bernard.

FM_new_dev

  • Member
  • *
  • Posts: 3
Re: Drag and Drop email & attachment from outlook directly
« Reply #3 on: February 01, 2016, 02:46:26 AM »
Thanks Bernard For your responce, really appreciate it.

I am just at the cross roads of thinking what to proceed, customer is quite eager on having this functionality as any other 'drag and drog' feature and probably wouldnt settle for anything less.
How near does it take user to attach emails / email attachments after this is implemented? Do u have any snapshot of this solution implemented?

I am thinking about trying any other mail client if that can solve the problem?


Bernard De Jonghe

  • Member
  • *
  • Posts: 17
Re: Drag and Drop email & attachment from outlook directly
« Reply #4 on: February 01, 2016, 05:20:12 AM »
In windows the drag and drop from a mail client to filemaker will not work.
I'm not sure if it works on Mac.  I never tested this.
Just because of this drag and drop problem, I followed another route.

As I explained I first use the Outlook Manipulator to get all the mails in Filemaker.  I both download the Inbox and the Sent Items, and bring these in one table.  With an icon I indicate if the mail is incoming or outgoing.
The mail messages are also stored in the mail repository and the attachments are also stored in the attachment repository, as described earlier.

Next I created links from the Mail table to other tables in my database (e.g. Companies, Contacts, Projects, Orders, etc.), and I can link messages to any record in these tables.
I can manualy link, but I can also link on an automatic way certain mails.

I give you an example:
All mails in a discussion have one field in common, the Thread Index.  So if you link one mail of a discussion, you can pick up the Thread Index, look for all mails with the same Thread Index, and link them automatically. 
Doing so, you can save a lot of time.

A second Idea is the following:
If I send a mail, I make sure I add a unique code in my signature.
If your contact replies to such a mail, the code remains in the body of the mail.
So once the mails are in filemaker, you can use a script the searches the body field for this unique code, and use this info to link the mail to a record in another table.  and again, once this is done, you know the Thread Index, and you can search for other mails with the same Thread Index.
The unique code could for example be: **-**22016054**-**
Then in the script look for the pattern **-**, and grap the number behind it. 
In my case the first "2" = Projects Table and "2016054" is the record number.

Finally, once mails are linked to records in other tables, I grap the message.msg files and the corresponding messages, and I export them to a folder on the server that is unique for each order, or project, or...
As the files I export to these folders are already timestamped, they automatically appear in chronological order in my folders.  And so I can see very easily the history of an order or a project for example.

And to do all this, I followed the idea of productive computing to implement all these scripts on a separate computer that acts a robot machine.  In my case it is actually a virtual machine on my physical server.

Hope these ideas help.
Bernard.

FM_new_dev

  • Member
  • *
  • Posts: 3
Re: Drag and Drop email & attachment from outlook directly
« Reply #5 on: February 06, 2016, 02:19:48 AM »
Thanks Bernard,

Really appreciate time you spent in writing the reply, i will definitely have a go at this one. Currently, customer has agreed to do a 2 step process. dropping the email / attachment to File System and then do another drag-drop onto the container field.

Is there a way to restrict emails coming into the filemaker or you have to download all emails / attachments into filemaker. In my case, may be we need selected emails / attachments to be saved with record.

Thanks

Bernard De Jonghe

  • Member
  • *
  • Posts: 17
Re: Drag and Drop email & attachment from outlook directly
« Reply #6 on: February 11, 2016, 12:28:43 PM »
Sorry for answering late.

To answer your question:
I actually synchronize the complete Inbox and the Sent Items with the filemaker database.

If in Outlook I move a message from the Inbox into the deleted items, my script takes the items in this deleted items folder one by one, and tries to delete them from the filemaker database. 
If this is done, the deleted items folder is emptied with the function PCEM_EmptyAllDeteledItems.
If in Filemaker I mark a message (already in the database) for deletion, the script moves it to the deleted items folder in Outlook and deletes it from Filemaker.

I'm currently in the process of testing and launching all my scripts to do all this. 
If everything works fine, I'll be glad to share my experience with others.  I need a little more time to get there  :)

I'll keep up informing in this forum.

Bernard.