1 2 Previous Next 24 Replies Latest reply on Jan 17, 2013 11:02 AM by philmodjunk

    Exporting/Emailing Files

    MaxwellRobin

      Title

      Exporting/Emailing Files

      Post

           Hi All!

           So what I would like is to export and email files from my database including the dtabase file itself.

            

           EXPORTING

           I have a container field in my database that the user can use to hold a file in the database

           i have a layout with buttons on it and one is being used to export this file

           is there a way to have the button run a script that allows the user to save the file to anywhere on their computer?

           is there also a way to have the user be able to click a button that allows them to save the database itself to the computer or an external drive?

            

           EMAILING

           in the same veign as above i would like the user to be able to email both these files to anyone.

           the database has a table with contacts including people's emails

           is there a way to have the user click the button and have a popup dialog ask if they would like to email someone in the contact list or a new person

           essentally i would like the user to click a button and then be able to select one or multiple recipients from the contact list or be able to type in a new email.

           after reciepients have been selected i would like the file in the container field to become attached to the email

           if the user clicks another button and after reciepients have been selected i would like the database to become attached to the email

            

           is this possible?

            

           thank you!

        • 1. Re: Exporting/Emailing Files
          philmodjunk

               Export FIeld Contents can export a file in a script and if you do not specify, the output file name or location, a dialog will pop up for the user to select a location and file name for the exportefile.

               The same is true for Save a Copy As... -- but this only works if your file is not hosted over the network.

               For emailing a file stored in your container field, you can export a copy to a standard location such as the temporary items folder by using a variable to specify the name and location for the exported copy. THen send mail can use this very same variable to attach the file to an email.

               Like wise, save a copy as can use a variable in the same way to save a copy of the file for attaching to an email.

          • 2. Re: Exporting/Emailing Files
            MaxwellRobin

                 I do not host my database over a network but i will sometimes use the remote database function to allow multiple users to work on the same database at the same time. is that what you mean? if so is there a way around it or would i just have to save a copy as when its not networked? if networked can the main host save a copy as?

                 when emailing i would like the user to be able to select an email from a field in another table, which has a contact list. is this possible? is it also possible to allow the user to select multiple emails from a list in that table, as well as type an email that doesnt exist in the list?

                  

                 Thank You!

            • 3. Re: Exporting/Emailing Files
              philmodjunk

                   Yes, that is what I mean. In that situation, Save A Copy as is only funcitonal from your copy on the computer that the others are remotely accessing. Thus, you do not have to wait til it's off the network but you do have to do this action from the host computer's copy of FileMaker Pro.

                   Yes, the email actions you describe are possible, provided the user has an email client that is compatible with FileMaker or access to an SMTP email server. The details to how you would do this depend in part on how you structure your database and what you want to do. There is both a "Multiple Emails" option in the send mail dialog and it is also possible to construct a list of email addresses in the "TO" box of send mail. The listed emails would be separated by commas or semi colons depending on which delimitter is required by the email client program.

              • 4. Re: Exporting/Emailing Files
                MaxwellRobin

                     Awesome! So what happens when a user who is remotely accessing the database clicks the button that performs the save a copy as script? Can i have a Get function that sees if the user is on the remote and then pops up a custom dialog?

                     Lets assume the user is using the preloaded apple mail application. The list of emails should come from TeamContacts::Email. Do I need a check box for the user to select emails?

                      

                     Thank You!

                • 5. Re: Exporting/Emailing Files
                  MaxwellRobin

                       Also, on an unrelated topic. I have a script attached to a button that inserts an image into a container field. When i click cancel after the window pops up for me to select a file a dialog pops up saying the script has been cancelled would you like to continue? i would like to cancel the script. is there a way to have the dialog not pop up and have the script click cancel for me?

                  • 6. Re: Exporting/Emailing Files
                    philmodjunk
                         

                              So what happens when a user who is remotely accessing the database clicks the button that performs the save a copy as script?

                         The script fails to save a copy.

                         

                              Lets assume the user is using the preloaded apple mail application. The list of emails should come from TeamContacts::Email. Do I need a check box for the user to select emails?

                         Perhaps, but it's not the only option. Drop down lists, portals, performing finds, etc all might play a role here. And some of these other options may be a much more flexible option or one that is simpler to implement.

                         Much depends on what else is in your database. Will the messages sent be created from scratch by the user? Should such messages then be preserved in the database? Might the messages be messages that include data from your database? Should there be a series of standard message forms that combine text with data from the database such that the user just selects the message form and what record or group of records supplies data to that form? All of these options and more can be done and can affect your interface design--including how you go about selecting recipient email addresses for the email to be sent.

                    • 7. Re: Exporting/Emailing Files
                      MaxwellRobin

                           What ever you think is best to impliment these tasks:

                            

                           Send an email to one or multiple reciepients including emails in a seperate table as well as new ones not in the database

                           Selecting the emails should just be a one click task and the user should be able to deselect the email if there is a mistake

                           There are multiple things to be emailed:

                            

                           Files attached to the database in a container field

                           The database itself as a file

                           Some PDFs

                           Each email sent can contain one or multiple of these files. I would like a checkbox set to determine which files are to be emailed.

                            

                           Does this help?

                      • 8. Re: Exporting/Emailing Files
                        philmodjunk
                             

                                  Send an email to one or multiple reciepients including emails in a seperate table as well as new ones not in the database. Selecting the emails should just be a one click task and the user should be able to deselect the email if there is a mistake

                             I'm afraid that's just too vague to be able to suggest much in detail.

                             

                                  Each email sent can contain one or multiple of these files.

                             That's not possible with the send mail script step. You are limited to a single attached file for any given email. It's possible that a plug in might add the ability to support multiple file attachments.

                        • 9. Re: Exporting/Emailing Files
                          MaxwellRobin

                               i guess what i would like is for the user to select and deselect names from a list generated from the contacts table. when they select a name it puts the coresponding email in the "To" box. if you add another name it will add that email. if you select an email that is already in the "To" box it will remove it from the "To" box. does that help more?

                               is there a way to have it send multiple emails with the same email "To" list but each file on its own?

                          • 10. Re: Exporting/Emailing Files
                            philmodjunk

                                 Yet the best method depends on the overall structure of your system and whether you need to keep the emails in a table for future reference after they have been sent. You could use such a list of selcted recipients with a script that performs a find on the table of email addresses. With that method, the "multiple emails,one for each record in found set" option can be used to send an email to a group of recipients. But with other approaches, you can construct a list of email addresses in the To box separated by delimtter characters. The end result is the same, but the structure of your database can make one method a better fit than the other.

                                 The problem with a check box field is that it must be formatted to display a finite number of check boxes, yet the number of email addresses in your table are likely to change constantly. Here's an alternative approach:

                                 EmailMessages------<RecipientList>-----EmailAddresses

                                 EmailMessages::__pkMessageID = RecipientList::_fkMessageID
                                 EmailAddresses::__pkEmailAddressID = RecipientList::_fkEmailAddressID

                                 See the first post of this thread if this notation is unfamiliar: Common Forum Relationship and Field Notations Explained

                                 With that structure, you can set up a portal to RecipientLIst on an EmailMessages based layout. RecipientList::_fkEmailAddressID can then be formatted as a drop down list or pop up menu of __pkEmailAddressID values in field 1 and a name field from the same table as the secondary field. You can then select a series of recipients for your email, one in each row of this portal. Then this expression can be used to produce a list of email addresses for the To box in Send Mail:

                                 Substitute ( EmailAddresses::EmailAddress ; ¶ ; "; " )

                                 with some email clients, you may need to use a comma instead of a semi-colon.

                                 On the other hand, with the above structure, you might also be able to use Go To Related Records to pull up a found set of email address records and then you can use the "multiple emails..." option. But this requires a different approach for setting up the body of the email.

                                 And it would be possible to do multiple send mails from the same EmailMessages record--one for each attached file.

                            • 11. Re: Exporting/Emailing Files
                              MaxwellRobin

                                   i do not need to keep emails for future reference.

                                   my idea with the checkbox was to put one checkbox in each record and have a looping script run to see if the check box is selected in each record and if it is it will input the email field in that record.

                                   the email client i am using uses a "," to seperate the multiple emails in the "To" box.

                                   how would i go about setting up sending multiple emails to send when multiple files have been selected?

                                   i dont mind which method we use as long as it is easy for the user to work with.

                                   what i have is a table with one field and two checkbox fields.

                                   the user can select one to five boxes and then click the email button.

                                   when they click the email button the database can send the user to a table with the email list and a check box in each record.

                                   when they click the send button it will create a blank email. input all the reciepients. and one file. if multiple files have been selected it will then create a new blank email with the same reciepients and the other file. this will repeat until all the selected files have been inputed into emails.

                                    

                                   does this make sense?

                                    

                                   thanks

                              • 12. Re: Exporting/Emailing Files
                                philmodjunk
                                     

                                          my idea with the checkbox was to put one checkbox in each record and have a looping script run to see if the check box is selected in each record and if it is it will input the email field in that record.

                                     This will not work if you have more than one user doing this at the same time, each will get all selections made by all such users. You also have to clear the selections made each time.

                                     

                                          what i have is a table with one field and two checkbox fields.

                                     

                                          the user can select one to five boxes and then click the email button.

                                     Not sure what you mean there, "two checkboxes"? "one to five checkboxes"? and what is selected when they do this?

                                     To send out two emails to the same recipients, but with a different attachment to each simply requires putting two send mail script steps in the same script, one for each attachment. If you have a pair of check box values for selecting which combination should be sent, you can include the send mail steps inside "IF" blocks that check the value of the check boxes. The exact syntax you'd use to check the values selected would depend on whether you add two different fields with single check box formats to your layout or one field with two checkboxes.

                                • 13. Re: Exporting/Emailing Files
                                  MaxwellRobin
                                       

                                  For emailing a file stored in your container field, you can export a copy to a standard location such as the temporary items folder by using a variable to specify the name and location for the exported copy. THen send mail can use this very same variable to attach the file to an email.

                                  how do i do this? i would like to store the file in a temporary location so it does not clog up the hard drive. once the file is sent it no longer needs to be stored. thanks!

                                  • 14. Re: Exporting/Emailing Files
                                    philmodjunk

                                         Set Variable [$Path ; value: "file:" & Get ( TemporaryPath ) & "filename.extension"] --> specify the correct extension for the file that is inserted
                                         Export Field Contents [ YourTable::YourContainerField ; $Path]

                                         and then you can type $Path (no quotes) into the dialog that opens when you select the attach file check box in the send mail dialog to attach this file.

                                    1 2 Previous Next