12 Replies Latest reply on Feb 7, 2012 2:07 AM by listen2earth

    saving sent messages by email

    dunumba

      Hi, this is my first question in this great forum. I'm a spanish non-professional developer and I need any help about saving sent messages by email.

      I've no problem with the mailing setup with Filemaker, but my client ask me to save every sent email with all his related data.

      Is there any way to get that?

      It would be something similar to Business Productivity Kit 3.0 (from Filemaker, Inc.), but with an automatic selection of the mail recipients.

      Thanks,

       

      Dunumba

        • 1. Re: save sent messages by email
          MicheleOlson

          Hi Dunumba,

           

          Take a look at FM StartingPoint 2.1 from Richard Carton Consulting. <http://www.fmstartingpoint.com/>.

           

          One of the modules sends and saves emails. You can either use Starting Point as the basis of your system, or study the module within StartingPoint and add something similar to yours.

           

          HTH,

           

          Michele

          • 2. Re: save sent messages by email
            RayCologon

            dunumba wrote:

            ...my client ask me to save every sent email with all his related data.

             

            Hello Dunumba,

             

            You haven't said  much about how the emails are being created and sent in your solution, however I'd suggest you save them as data in a form that can easily be searched, reviewed or re-sent by the user.

             

            To do that, I'd suggest that you create an EmailLog table with an auto-enter (serial number) key field, fields for each of the parts of the email (to, subject, body etc). Then from the table occurrrence (TO) context where the user will be sending the emails, create a relationship to the EmailLog table that matches a global field (in the existing TO) to the key field in the EmailLog table, and turn on the option to "Allow creation of records in this table via this relationship" for the EmailLog table.

             

            With the above in place, in each script that sends an email, add a few steps (eg after the Send Mail[ ] step), along the lines of:

             

              • If [Get(LastError) = 0]
                • Set Field [YourTable:gUtility; ""]
                • Set Field [EmailLog::Date; Get(CurrentDate)]
                • Set Field [EmailLog::To; {your list of recipient email addresses}]
                • Set Field [EmailLog::Subject; {your email subject line}]
                • Set Field [EmailLog::Body; {your email subject line}]
                • Set Field [EmailLog::Status; "Sent"]
                • Set Field [EmailLog::LastActivity; Get(CurrentTimestamp)]
              • End If

             

            With this in place, a new log record will be created whenever an email is successfully sent. It's then a relatively simple matter to create a log view layout or two that will allow your client to search and view the contents of the EmailLog table.

             

            If the emails your solution sends also include attachments, you'll need to decide how to handle them - eg whether to store them in a container field (which may lead to the file size becoming large) or store them elsewhere and include the path to the attachment in a text field in the EmailLog table. These and other options can be implemented fairly easily, but which is best will depend on the functionality your client requires.

             

            Regards,

            Ray

            ------------------------------------------------

            R J Cologon, Ph.D.

            FileMaker Certified Developer

            Author, FileMaker Pro 10 Bible

            NightWing Enterprises, Melbourne, Australia

            http://www.nightwingenterprises.com

            ------------------------------------------------

            1 of 1 people found this helpful
            • 3. Re: save sent messages by email
              dunumba

              Hello Ray,

              Thanks you for your answer.

              The emails are being created with a script in some different layouts. The messages are sent to a single recipient and also to a recipients group obtained from a search.

              I think that your suggestion is the best way to save sent emails, and I’m going to try it.

              I’m really impressed by your generosity in sharing your work. Thank you very much!!

              Dunumba (my real name is Damian)

              • 4. Re: save sent messages by email
                RayCologon

                dunumba wrote:

                ...The emails are being created with a script in some different layouts...

                 

                Hi Damian,

                 

                That shouldn't be a problem. What matters is whether the layouts from which the emails are sent are based on the same table occurence. If they are, then the approach I outlined above should work from each layout - though you may need to make adjustments to ensure the email content is captured correctly from each of the layouts.

                 

                If the layouts are based on different TOs, you may need to repeat the steps for each TO, and either use different scripts for each, or use some If/ElseIf sequences to ensure your script works correctly from each context.

                 

                All the best,

                Ray

                ------------------------------------------------

                R J Cologon, Ph.D.

                FileMaker Certified Developer

                Author, FileMaker Pro 10 Bible

                NightWing Enterprises, Melbourne, Australia

                http://www.nightwingenterprises.com

                ------------------------------------------------

                • 5. Re: save sent messages by email
                  dunumba

                  Hi Ray,

                  Thanks. I've another questions:

                   

                  • What is the global field content? Is it necessary to enter some code or number?
                  • Can I save from this relationship a reference or link to every sent email in the user record (with a portal, of course)
                  • The whole Database is composed of several sections: teachers, students, families, etc. So, perhaps it'd be better creating a different Email-log table for every section. What do you think about it?

                   

                  All the best

                  Damián

                  • 6. Re: save sent messages by email
                    RayCologon

                    dunumba wrote:

                    Hi Ray,

                    Thanks. I've another questions:

                    • What is the global field content? Is it necessary to enter some code or number?

                     

                    Hi Damián,

                     

                    When the script sequence  I described runs, FileMaker will automatically place the next serial number from the auto-enter serial key field in  the EmailLog table into the global field to create eh relationship connection (which will then allow you to write to the new EmailLog record). So you don't need to put anything there, only to clear the previous value before creating a new log entry, which is why the first Sedt Field[ ] command clears the global field (by setting it to "").

                     

                    dunumba wrote:

                    • Can I save from this relationship a reference or link to every sent email in the user record (with a portal, of course)

                     

                    For that purpose, I'd suggest you set up a separate relationship. To do that, you would need to add an additional TO of the EmailLog table, so that you can connect it however you like (eg filtering based on a Sender field in the EmailLog table, for instance).

                     

                    dunumba wrote:

                    • The whole Database is composed of several sections: teachers, students, families, etc. So, perhaps it'd be better creating a different Email-log table for every section. What do you think about it?

                     

                    I would suggest that you make only one EmailLog table, and place multiple TOs of it on the graph, connecting one to each of the sections from which emails will be created. You might like to add a 'Type' field in the EmailLog where you can record which section an email was created from.

                     

                    One benefit of putting all the data in one table is that when users search (eg for emails sent to a particular address) they will get all emails returned from a single search. You can easily filter the search results (or portal displays etc) by the type field, but if you put them into separate tables a lot of things will be harder and the structure will be less flexible.

                     

                    Regards,

                    Ray

                    ------------------------------------------------

                    R J Cologon, Ph.D.

                    FileMaker Certified Developer

                    Author, FileMaker Pro 10 Bible

                    NightWing Enterprises, Melbourne, Australia

                    http://www.nightwingenterprises.com

                    ------------------------------------------------

                    1 of 1 people found this helpful
                    • 7. Re: save sent messages by email
                      dunumba

                      Hello Ray,

                      I've just tried your suggestion and everything goes perfect except the recipient field:

                      • When I'm sending an email from the students section, there is no problem: the email log is generated and all fields are OK.
                      • But when I'm trying to send an email to more than one recipient, the email log is generated ok except the adress field. For example, If I send an email to three recipients, filemaker generates three records with the adress field empty.

                      Should I make some change in the adress field setup, or perform a new script?

                       

                      Thanks

                      Damián

                      • 8. Re: save sent messages by email
                        RayCologon

                        dunumba wrote:

                        ...when I'm trying to send an email to more than one recipient, the email log is generated ok except the adress field. For example, If I send an email to three recipients, filemaker generates three records with the adress field empty.

                        Should I make some change in the adress field setup, or perform a new script?

                         

                        Hi Damián,

                         

                        It's hard to say why that's the case without seeing your script, but if a log entry is generated for each email, it sounds as though the script is running once for each message?

                         

                        Regardless, what I'd suggest you do when there are multiple messages going out is have the script complete sending them all - if necessary using a Loop/End Loop sequence to work its way through a list of addresses, then generate the log entry once at the end. If the scripted loop is working through a supplied email address list, then your Set Field[ ] targeting the EmailLog::To field can simply place the list into that field, otherwise (eg if the scipt is looping through records sending the email to an address found on each) you may have to have the script build the list as it goes.

                         

                        If these suggestions don't point to a solution that works for you, I suggest you post a transcript of the script you're using and describe when it is being called from each layout. Then it may be possible to suggest some other alternatives.

                         

                        Regards,

                        Ray

                        ------------------------------------------------

                        R J Cologon, Ph.D.

                        FileMaker Certified Developer

                        Author, FileMaker Pro 10 Bible

                        NightWing Enterprises, Melbourne, Australia

                        http://www.nightwingenterprises.com

                        ------------------------------------------------

                        • 9. Re: save sent messages by email
                          dunumba

                          Hi Ray, I fixed the problem using a Loop/End Loop Sequence

                          You can see the script in the attachment.

                          When you come to Salamanca (Spain), please, contact me, I must to invite you to a nice dinner and party!!!

                          Thanks

                          Damián

                          • 10. Re: save sent messages by email
                            RayCologon

                            dunumba wrote:

                            Hi Ray, I fixed the problem using a Loop/End Loop Sequence

                            You can see the script in the attachment...

                             

                            Hi Damián,

                             

                            Glad you've made some progress with it.

                             

                            Using the loop as you have it set up, the script will be generating a separate log entry for each email. If that's doing what you want, then - no problem! However if you'd prefer to have only one log entry with a list of all the recipients in the 'correo destinatario email' field, an alternative would be to perform the loop through the records separately first, adding each email directión entry to a variable, to build a full list - then, after the loop exits (Salir después del último), have the Establecer Campo [ ] steps to create a single log entry, putting the result of the variable (which now has a list of addresses) into the recipients field.

                             

                            Meanwhile, I hope I may visit Spain someday, and appreciate your kind suggestion. I must say, though, that your English is a lot better than my Spanish!

                             

                            Regards,

                            Ray

                            ------------------------------------------------

                            R J Cologon, Ph.D.

                            FileMaker Certified Developer

                            Author, FileMaker Pro 10 Bible

                            NightWing Enterprises, Melbourne, Australia

                            http://www.nightwingenterprises.com

                            ------------------------------------------------

                            • 11. Re: save sent messages by email
                              dunumba

                              Thanks you, Ray. My client prefers to have a separate log entry for each email, but I'talking to her about the other alternative.

                              No matter your Spanish for enjoying here!!

                              All the best

                              Damián

                              • 12. Re: save sent messages by email
                                listen2earth

                                Good day

                                 

                                i am jumping in here because i never can find the link for posting.

                                 

                                Looking for someone who knows how to

                                 

                                GetNumberWord (field)

                                 

                                i am needing number of a selected word.  There's the function WordCount that returns the total number. But i just want the number of a selected word.

                                 

                                Thank you

                                r o b