10 Replies Latest reply on Sep 13, 2013 7:40 PM by mrosenhek

    Attaching Document to Mail

    mrosenhek

      Is there a way to attach a document to an email, automatically.

      I realize attaching a file to an email is simple but let me explain ...

       

      Portal row contains a document.

      User wants to click button on portal row to automatically address an email to the parernt record which is easy enough (email field exists), but also wants to auto attach the document in the portal row to the email. I can't hard code the file path as it will vary.

       

      I can create a field to contain the file path I suppose, but there is no place in the Send Mail dialog I can see to specify that field, to indicate the file path of the file

       

      Any takers on this? Thanks.

        • 1. Re: Attaching Document to Mail
          bkeizer

          I would suggest having the script export the field contents to temporary folder.  Using that temporary folder location as the static reference in the Send Mail dialog.  That way it doesn't have any impact on your file storage structure.

          • 2. Re: Attaching Document to Mail
            erolst

            mrosenhek wrote:

             

            […] but there is no place in the Send Mail dialog I can see to specify that field, to indicate the file path of the file

             

            Calculate a storage location, put it into a variable, then use this variable to first export your file (e.g. into the Temp folder which be deleted when you quit FileMaker), then to specify the path for the attachment:

             

            SendMail_attachmentFilePath.png

            • 3. Re: Attaching Document to Mail
              mrosenhek

              Export the field? Not sure what you mean. Export the field in the record that has a file path in it?

              Where do you export it to?

               

              The documents will be stored in a folder somewhere on the users desktop (at least for now as it will be a single user solution for the time being).

               

              Sorry for not fully understadning your instructions.

              • 4. Re: Attaching Document to Mail
                mrosenhek

                Oh I see what you mean.

                Thanks.

                • 5. Re: Attaching Document to Mail
                  mrosenhek

                  Now I think I see what you meant. Similar to BKeizer.

                  Thanks.

                  • 6. Re: Attaching Document to Mail
                    keywords

                    I regularly use a script along the following lines to accomplish this:

                     

                    Allow User Abort [ Off ]

                    Set Error Capture [ On ]

                     

                    Set Variable [ $requestName; Value:Let( [

                          mainpath = "/defineTheLocationPath/" ;

                          name = "someText" & aCalculatedValuedBasedOnTheCurrentRecord (in my case, client name) ;

                          ref = anotherCalculatedValuedBasedOnTheCurrentRecord (in my case, record number) ;

                          extension = ".pdf" ;

                    $filepath = "file:" & mainpath & name & ref & extension ;

                    $imagepath = "image:" & mainpath & name & ref & extension ] ;

                    $filepath & "¶" & $imagepath ) ]

                     

                    Perform Script [ “ PAGE SETUP_tall” ]

                     

                    Save Records as PDF [ File Name: “$filepath”; Current record ]

                    [ Document - Compatibility: Acrobat 5 and later ]

                    [ Pages - Number Pages From: 1; Include: All pages ]

                    [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ]

                    [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]

                    [ Restore; No dialog ]

                     

                    Send Mail [ Send via E-mail Client ; To: emailAddressFromCurrentRecord ; Subject: "yourTextAsRequired" & calculatedTextFromCurrentRecordAsRequired ; Message: "Dear(or other greeting) " & calcToAddNameFromCurrentRecord & ",¶¶" &

                    "Whatever message text you want to hardcode here.¶¶Regards (or other signoff),¶yourName¶¶"; Attachment: “$filepath” ]

                    • 7. Re: Attaching Document to Mail
                      bkeizer

                      The one modification on this script that I would add if you are only using the export to attach it to an email is to use temp folder so that it will auto cleanup when rebooting.  It is very simple if you use the Get(TemporaryPath) function.

                       

                      Set Variable [ $path; Get(TemporaryPath) & "my_temporary_file.jpg" ]

                       

                      Hope this helps.

                       

                      Ben

                      • 8. Re: Attaching Document to Mail
                        mrosenhek

                        Thank you very much Ben. It will be a while till I start on this (if they even go witht he project, yet unknown).

                         

                        -Moe

                        • 9. Re: Attaching Document to Mail
                          keywords

                          I agree with you Ben, if there is no reason to keep the exported document outside of FileMaker. My business logic requires that I keep copies of documentation as it was supplied to clients, so I define a permanent storage location. I think it is extermely useful that FM provides readily for both approaches.

                          • 10. Re: Attaching Document to Mail
                            mrosenhek

                            I agree too. This is a new client and they are not even so sure what they want. I'm coaxing requirements out of them to get an idea of what to estimate for the work. Trouble is that now they tell me I am not a "pre approved" vendor so I think that will be a bigger challenge than the coding (it's for the city). I'll let them figure it out, hopefully they resolve it because the city would have good potential, although their IT  refuses to support FM. Anyway, the client is keen so perhaps they can figure out what I need to do to be "pre approved".

                             

                            I love approval  ... lol.