8 Replies Latest reply on Mar 10, 2016 3:31 AM by andresen

    Can an email be saved as an attachment in a container field?

    miw

      Title

      Can an email be saved as an attachment in a container field?

      Post

           I have a file that has a container field.  I have no problem adding a document to the container field or saving the reference of a document to the container field.  What I would like to also do is save an actual email in the container field.  When I drag an email from Mail to the container field, it looks like it will work - I get the little "+" icon as I am dragging the email to the FM window, but it looks like nothing is saved.  Is there anyway to save an email in the container field?

        • 1. Re: Can an email be saved as an attachment in a container field?
          philmodjunk

               From what are you dragging the email? A window to your inbox opened by your email client program? Or a window to a folder of email files opened via your operating system?

               If you drag and drop from an OS controlled window (not the email application), I would expect this to copy the file into the container field. But drag and drop in FileMaker 12 is the equivalent of "insert Picture" so this may not be the best way to insert the email file. Using Insert File from the Insert menu is likely to work better. And if you are doing a drag and drop into a FileMaker 11 or earlier file on windows, you get an Insert Object operation. While this seems like a nice way to go at first, it has severe limitations that can mouse trap you into hours of "hand labor" should you ever need to export large numbers of files from your container fields as you cannot export the file contents in any way when it is an inserted object--which may be why FileMaker 12 no longer supports "insert object".

               The challenge to all this may be in finding that file of emails without using the email client program to access an inbox. You'll also need to see if directly double clicking such a file successfully opens it in your email program or this will all be for naught.

          • 2. Re: Can an email be saved as an attachment in a container field?
            miw

                 Using FM 12 Advanced, I was dragging the email directly from the inbox of the Apple Mail application.  It looks like I can drag the email to the desktop first and then drag it to the attachment field.  But I can only drag it - if I right click and try to insert the email, it is grayed out and not allowed.  If I want to retreive the email I can only open it by first saving the file somewhere (like I would most docs).  Seems like a lot of steps...

            • 3. Re: Can an email be saved as an attachment in a container field?
              philmodjunk

                   I can only open it by first saving the file somewhere

                   By "save" do you mean using Export Field Contents to export a copy and then open it?

                   That is correct, given that you are using drag and drop--which puts a physical copy of the file into the container field. Only files inserted with Insert File and "store a reference" specified can be opened by double clicking the container field. (And some FileMaker 12 data formats can disable this option even then.)

                   When you say "it is greyed out and not allowed", exactly what method are you using? Are you using Insert File?

                   All those extra steps can be automated via a script.

                   You might set up a script to export a copy of the file dropped into your container field to a specified location and then re-insert the file to with the "store a reference" option. This then produces a double-clickable container field for re-opening the email file.

              • 4. Re: Can an email be saved as an attachment in a container field?
                miw

                     Yes, by "save" I did mean that I had to use the Export Field Contents to export a copy and open it at the same time.  As for the "grayed out" issue, I was using the insert file command for the container field - it would not recognize the email if I used the insert picture - you are correct that I should have been using the "insert file" command instead.

                     Your last sentence noted a script to export the container field and then re-insert it with the "store a reference" option which makes it double click-able.  That would be nice - if I want to export the file to a "My FM Docs" folder in a folder named "My FM App" (i.e. in the "My FM App" folder I would find my FM application and the "My FM Docs" folder which then has the exported documents mained by my FM App.) what would such a script look like?

                • 5. Re: Can an email be saved as an attachment in a container field?
                  philmodjunk

                       You'll need to be able to specify the full path to that folder named "My FM Dos" in a variable. Since I don't know that path, I will subsitute a reference to your Documents folder:

                       Set Variable [$FileName ; value:
                       Let ( [T = GetAsText ( GetValue ( YourTable::containerField ; ValueCount ( ContainerTest::containerField ) ) ) ;
                                   L = Length ( T )];
                                   Right ( T ; L - Position ( T ; "/" ; L ; -1 ) )
                           )
                       ]
                       Set Variable [$Path ; value: "file:" & Get ( DocumentsPath ) & $Filename ]
                       Export Field Contents [YourTable::ContainerField ; "$Path" ]
                       Insert File [Reference ; never compress ; YourTable::ContainerField ; "$Path" ]

                       You'll need to replace the blue text with the / separated list of folders starting with either a windows drive letter or a mac volume name.

                  • 6. Re: Can an email be saved as an attachment in a container field?
                    miw

                         PhilMod:  In your script step above, what is the ContainerTest::containerField?  Do I need to set up a new file with containerField as a container?  Is it a global field?  So far I am not able to get the script to work - I end up with the following FM error message: ""could not be created on this disk.  Use a different name, make room on the disk, unlock it or use a different disk."  I know the disk is not the issue; it seems I cannot get the $FileName to get a result that is not null.

                          

                         Thanks for the help

                    • 7. Re: Can an email be saved as an attachment in a container field?
                      philmodjunk

                           Apologies. that table and field name combination was from the test file where I made sure that this calculation worked. I should have posted:

                           Set Variable [$FileName ; value:
                           Let ( [T = GetAsText ( GetValue ( YourTable::containerField ; ValueCount ( YourTable::containerField ) ) ) ;
                                       L = Length ( T )];
                                       Right ( T ; L - Position ( T ; "/" ; L ; -1 ) )
                               )
                           ]

                           This use of GetValue get's the last return separated value from the text returned from your container field--which can vary depending on the options used to insert or import the file.

                           The error message that you report indicates that you have probably used an invalid file path--that's the most typical reason you get this error--which really should just say "Filemaker was unable to create this file at <FilePathHere>"

                           The empty quotes in this message indicate that you aren't getting a file name into your path variable.

                      • 8. Re: Can an email be saved as an attachment in a container field?
                        andresen

                        Hi

                        I'm trying to do the same I think. From an open email program (outlook) on a Mac. Drag it to the container in my FM table.

                        I have tried to do was the result is above but I get an error in second to last row.

                         

                        Did I correct understand that this is a script?

                         

                        Variabels: $FileName ?

                        Variabels: $Path ?

                         

                        Get (Document path) = what?

                         

                        Take a look, I made a try.script try.tiff