14 Replies Latest reply on Jan 2, 2013 3:16 PM by philmodjunk

    Attach Map snapshot to email

    EP

      Title

      Attach Map snapshot to email

      Post

           I'm trying to create a script that upon clicking a button, pre-populates an email with a contacts information and a snapshot of a map containing their address.  I believe I have to create a new layout with a container field for the map.  Can someone provide an example of what other fields are needed on this layout?

           Thanks

        • 1. Re: Attach Map snapshot to email
          philmodjunk

               What other fields would you need?

               Is this layout one that you want to save as PDF and attach to the email?

               Or do you want to include the contacts info as plain text in the body of the email and just attach a snapshot of the map?

               The second option shouldn't require creating a special layout for that purpose.

          • 2. Re: Attach Map snapshot to email
            EP

                 Plain text email and attach a snapshot of the map (second option)

            • 3. Re: Attach Map snapshot to email
              philmodjunk

                   Hmm, I may have spoken too hastily.

                   I was thinking that Insert From URL could be used to insert the map image into a container field and then the container field image could be exported inorder to generate the needed image file to attach to the email. But that requires a URL to a file to be downloaded from a web site and a google map isn't (as far as I know) accessible as a downloadable file and even if it were possible, you'd need to use a layout with the container field on it in order to insert the file.

                   I think you may need to put a web viewer to google maps on a layout and then use save as PDF to get an image file that you can attach to your email. That would require a layout with a web viewer placed, sized as needed for your map image and you could just have the web viewer or you could include the other contact fields on this layout at your option.

              • 4. Re: Attach Map snapshot to email
                EP

                     Ok.  I'm looking at how they did it in the started solution.  They didn't use save as PDF, rather set a variable and somehow able to pull a .png.  I'm looking into it to see if I can figure it out.

                     Thanks

                       

                • 5. Re: Attach Map snapshot to email
                  philmodjunk

                       Which Starter Solution? And on  what layout of that solution do you find this?

                       I took a quick look at the FMP 12 Contacts Starter Solution and didn't spot that capability.

                  • 6. Re: Attach Map snapshot to email
                    EP

                         Phil I attached the script.  It was from the Contacts starter solution I believe.  (If not I can't remember where I borrowed it from....) 

                    • 7. Re: Attach Map snapshot to email
                      philmodjunk

                           Ok, that's what I originally thought was possible.

                           The insert from URL script step uses this expression:

                           Let     (
                               [
                               address =     Substitute     (
                                                       Contacts::Work Address 1& " " &
                                                       Contacts::Work Address 2& " " &
                                                       Contacts::Work City& " " &
                                                       Contacts::Work State& " " &
                                                       Contacts::Work Postal Code& " " &
                                                       Contacts::Work Country;
                                                       " " ; "+"
                                                       ) ;
                               size =         "512x256" ;
                               zoom =        14
                               ] ;

                               "http://maps.google.com/maps/api/staticmap?center="
                                       & address &
                                           "&zoom=" & zoom &
                                               "&markers="
                                                   & address &
                                                       "&size="
                                                           & size &
                                                               "&sensor=false"
                               )

                           Text shown in blue refers to values assigned by the Let function, which in turn references specific fields on the current record of the starter solution.

                           And this step then inserts the map image into a container field so that it can be exported to generate the correct image file. Export Field contents exports this to the current user's temporary items folder and the same $Path variable is then used in send mail to specify what file to attach to the email.

                      • 8. Re: Attach Map snapshot to email
                        EP

                             Thanks.  Am I correct that I still need to create a new layout with a container field for the map?

                        • 9. Re: Attach Map snapshot to email
                          philmodjunk

                               I forget some of the details of what you wanted, You would only need that if you were including the map image with other data in a PDF that you intended to attach to the email. If you are just attaching the email image, then you do not need a layout for that purpose.

                          • 10. Re: Attach Map snapshot to email
                            EP

                                 Phil, I slapped a layout together and got this working in just a few minutes, so it wasn't a big deal.  I ONLY need the map snapshot to attach to the email, so I guess I didn't need the other layout.  Any foreseeable issues with leaving it as is (with the layout)?  I don't want to take up etra space with map images, is that possible with my current setup or does the map download upon viewing a record and then delete when clicking out of the record?  Thanks

                            • 11. Re: Attach Map snapshot to email
                              EP

                                   Upon testing this on a windows 7 laptop with outlook 2007, the email contains an attachment of the map file, but it doesn't display in the body of the email.  Any workaround for this?  It works as it should (map in the email body) on a mac.

                              • 12. Re: Attach Map snapshot to email
                                philmodjunk

                                     Nature of the beast--the attached image will not appear in body of your email for those email clients. There are email plug ins that offer more options than FileMaker's Send Mail script step, so you may want to investigate those alternatives.

                                • 13. Re: Attach Map snapshot to email
                                  EP

                                       Phil, not sure if you saw my post from a couple days ago.

                                        

                                       "Phil, I slapped a layout together and got this working in just a few minutes, so it wasn't a big deal.  I ONLY need the map snapshot to attach to the email, so I guess I didn't need the other layout.  Any foreseeable issues with leaving it as is (with the layout)?  I don't want to take up extra space with map images in the records (create an excessively large file), is that possible with my current setup or does the map download upon viewing a record and then delete when clicking out of the record?  Thanks"
                                        
                                       Just wondering if you could shed some light.  Thanks,
                                        
                                  • 14. Re: Attach Map snapshot to email
                                    philmodjunk

                                         Well you don't need anything more than one global container field to manage your map images if you don't intend to retain them in your database. If your database is hosted over a network and you start with an empty container field when you first put the file up on the server, the contents of this field will automatically revert to empty each time a user closes a database.

                                         Even as a single user database, that one global field won't store a tremendously large amount of data.