6 Replies Latest reply on Oct 4, 2010 3:46 PM by DennyHayes

    Emailing Multi Page Emails

    DennyHayes

      Title

      Emailing Multi Page Emails

      Post

      Seems you can't email a multiple page email. This script works fine on a Mac, and you get one pfd file with multiple pages. But on the iPhone it only sends one page? A lot of this might seem confusing, because this script does some things while sending the email. Mainly it fills out a form to be saved. I'll try to attach an image of it.

      Line 31, which is the choice for emailing the pdf with the found set, does run because it sets all of the field info into the form. But line 32 seems to only save the first page to the documents folder

      ***********************************************

      1. If [ IsEmpty ( Preliminary Quotes::Serious Errors ) ] 
      2.    #---- Send Quotation Email ---------------------------- 
      3.    If [ IsEmpty ( Correspondence::Contact Email ) = 0 ] 
      4.       Go to Layout [ “Quotation Printout” (Preliminary Quotes) ] 
      5.       Set Variable [ $Variable; Value:Get ( DocumentsPath ) & Right ( Year ( Get ( CurrentDate ) ) ; 2 ) &      
      6.       Right ( "0" & Month ( Get ( CurrentDate ) ) ; 2 ) & Right ( "0" & Day ( Get ( CurrentDate ) ) ; 2 ) & "-" & 
      7.          Right ( "0" & Hour ( Get ( CurrentTime ) ) ; 2 ) & Right ( "0" & Minute ( Get ( CurrentTime ) ) ; 2 ) & " " & 
      8.          Preliminary Quotes::Quotation ID & "           " & Preliminary Quotes::Customer & ".pdf" ] 
      9.       Set Field [ Preliminary Quotes::Global Variable A; $Variable ] 
      10.       Print Setup [ Orientation: Portrait; Paper size: 8.5" x 11" ] [ Restore; No dialog ] 
      11.       #---- Select Multiple Or Single Quotation Email ---------------------------- 
      12.       If [ Get ( FoundCount ) = Get ( RecordOpenCount ) or Get ( RecordOpenCount ) > 10 ] 
      13.          Save Records as PDF [ File Name: “$Variable”; Current record ] [ Document -  Compatibility: Acrobat 5 and later ] 
      14.             [ Pages -  Number Pages From: 1; Include: All pages ] 
      15.             [ Security -  Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ] 
      16.             [ Initial View -  Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ] [ Restore; No dialog ] 
      17.       Else 
      18.          Go to Layout [ “Email” (Correspondence) ] 
      19.          Show Custom Dialog [ Message: "Do you want to email only the selected Single quotation, or all quotations in the Found set?"; 
      20.             Buttons: “Cancel”, “Single”, “Found” ] 
      21.          Go to Layout [ “Quotation Printout” (Preliminary Quotes) ] 
      22.          If [ Get ( LastMessageChoice ) = 1 ] 
      23.             Exit Script [  ] 
      24.          End If 
      25.          If [ Get ( LastMessageChoice ) = 2 ] 
      26.             Save Records as PDF [ File Name: “$Variable”; Current record ] [ Document -  Compatibility: Acrobat 5 and later ] 
      27.                [ Pages -  Number Pages From: 1; Include: All pages ] [ Security -  Printing: High Resolution; Editing: Any except extracting pages; 
      28.                Enable copying; Enable Screen Reader ] [ Initial View -  Show: Pages Panel and Page; Page Layout: Single Page; 
      29.                Magnification: 100% ] [ Restore; No dialog ] 
      30.          End If 
      31.          If [ Get ( LastMessageChoice ) = 3 ] 
      32.             Save Records as PDF [ File Name: “$Variable”; Records being browsed ] [ Document -  Compatibility: Acrobat 5 and later ] 
      33.                [ Pages -  Number Pages From: 1; Include: All pages ] [ Security -  Printing: High Resolution; Editing: 
      34.                   Any except extracting pages; Enable copying; Enable Screen Reader ] [ Initial View -  Show: Pages Panel and Page; Page Layout: 
      35.                   Single Page; Magnification: 100% ] [ Restore; No dialog ] 
      36.              Go to Record/Request/Page [ First ] 
      37.             #---- Set Email Field Info ---------------------------- 
      38.             Loop 
      39.                Set Variable [ $VariableA; Value:$VariableA & 
      40.                   Case ( IsEmpty ( $VariableA ) = 0 ; " " ) & 
      41.                   Preliminary Quotes::Quotation ID ] 
      42.                   Set Variable [ $VariableB; Value:$VariableB & 
      43.                   Case ( IsEmpty ( $VariableB ) = 0 ; "¶" ) & 
      44.                      Preliminary Quotes::Quotation ID & " " & 
      45.                      Preliminary Quotes::Customer ] 
      46.                Go to Record/Request/Page [ Next; Exit after last ] 
      47.             End Loop 
      48.             Go to Layout [ “Email” (Correspondence) ] 
      49.             Set Field [ Correspondence::Reference; Substitute ( $VariableA ; " " ; ", " ) ] 
      50.             Set Field [ Correspondence::Company; "Quotation Nos: " & $Variable ] 
      51.             Send Quotation Via Email Correspondence: Send Quotation Via Email 
      52.             Set Field [ Correspondence::Company Address; "" ] 
      53.             Set Field [ Correspondence::Company City; "" ] 
      54.             Set Field [ Correspondence::Company State; "" ] 
      55.             Set Field [ Correspondence::Company Zip Entry; "" ] 
      56.             Set Field [ Correspondence::Quotation ID; Substitute ( $Variable ; " " ; "¶" ) ] 
      57.             Set Field [ Correspondence::Body; "     Quotations:¶" & $VariableB & "¶" ] 
      58.          End If 
      59.       End If 
      60.       #---- Send Email ---------------------------- 
      61.       Go to Layout [ original layout ] 
      62.       Set Error Capture [ On ] 
      63.       Send Mail [ Send via E-mail Client; To: Correspondence::Contact Email; CC: Correspondence::Email CC To; BCC: 
      64.          Correspondence::Email BCC To; Subject: Correspondence::Reference & 
      65.          Case ( 
      66.             IsEmpty ( Correspondence::Reference ) = 0 and 
      67.             IsEmpty ( Correspondence::Subject ) = 0 ; " - " ) & 
      68.             Correspondence::Subject; Message: Correspondence::Body; Attachment: “$Variable” ] 
      69.       Close Window [ Current Window ] 
      70.       #---- Update Activity Log ---------------------------- 
      71.       Set Variable [ $Variable; Value:Left ( DayName ( Get ( CurrentDate ) ) ; 3 ) & ", " & 
      72.                Case ( Month ( Get ( CurrentDate ) ) < 10 ; "  " ) & 
      73.                   Left ( GetAsText ( Get ( CurrentDate ) ) ;  Position ( GetAsText ( Get ( CurrentDate ) ) ; "/" ; 0 ; 1 ) - 1 ) & "/" & 
      74.                   Right ( "0" & Middle ( GetAsText ( Get ( CurrentDate ) ) ; Position ( GetAsText ( Get ( CurrentDate ) ) ; "/"; 0 ; 1 ) + 1 ; 
      75.                      Position ( GetAsText ( Get ( CurrentDate ) ) ; "/" ; 0 ; 2 ) - 
      76.                      Position ( GetAsText ( Get ( CurrentDate ) ) ; "/" ; 0 ; 1 ) - 1 ) ; 2 ) & "/" & 
      77.                   Right ( GetAsText ( Get ( CurrentDate ) ) ; 2 ) & ", " & 
      78.                   Right ( "0" & Left ( GetAsText ( Get ( CurrentTime ) ) ; 
      79.                      Position ( GetAsText ( Get ( CurrentTime ) ) ; ":" ; 0 ; 1 ) - 1 ) ; 2 ) & ":" & 
      80.                   Right ( "0" & Middle ( GetAsText ( Get ( CurrentTime ) ) ; 
      81.                      Position ( GetAsText ( Get ( CurrentTime ) ) ; ":" ; 0 ; 1 ) + 1 ; 
      82.                      Position ( GetAsText ( Get(CurrentTime ) ) ; ":" ; 0 ; 2 ) - 
      83.                      Position ( GetAsText ( Get ( CurrentTime ) ) ; ":" ; 0 ; 1 ) - 1 ) ; 2 ) & "; " & 
      84.                      Get ( SystemIPAddress ) & " - " & 
      85.                   Substitute ( Get ( SystemNICAddress ) ; "¶" ; " - " ) & " (" & Get ( UserCount ) & ") " & 
      86.                      Get ( UserName ) & " (" & Preliminary Quotes::Active User & ") " & 
      87.                         Preliminary Quotes::Quotation ID & "-" & Preliminary Quotes::Job ID & 
      88.                         " (" & Preliminary Quotes::Customer w Address & ")" & " - Email" ] 
      89.        Go to Layout [ “Activity Log” (Activity Log) ] 
      90.       New Record/Request 
      91.       Set Field [ Activity Log::Activity; $Variable ] 
      92.       If [ Get ( SystemPlatform ) 3 and Get ( SystemPlatform ) 4 ] 
      93.          Go to Layout [ “Data Input” (Preliminary Quotes) ] 
      94.       Else 
      95.          Go to Layout [ “iPhone Record Review” (Preliminary Quotes) ] 
      96.       End If 
      97.    Else 
      98.       Show Custom Dialog [ Message: "Email To address is missing"; Buttons: “OK” ] 
      99.    End If 
      100. Else 
      101.    Send Quotation Via EmailCorrespondence: Send Quotation Via Email 
      102.       Show Custom Dialog [ Title: "Serious Errors"; Message: "The following error(s) were found, and must be corrected before the 
      103.       quotation can be printed:" & "¶¶" & Preliminary Quotes::Serious Errors; Buttons: “OK” ] 
      104. End If 



      Sotae.jpg

        • 1. Re: Emailing Multi Page Emails
          DennyHayes

          I also might mention that this script does not work on a PC for some reason, but in that case it simply will not save anything to the documents folder. So I doubt if it is caused by the same problem

          • 2. Re: Emailing Multi Page Emails
            TSGal

            DennyHayes:

            Thank you for your post.

            I am able to save and send multiple page PDF files from FileMaker Go.  Therefore, let's just start with some basics.  Here is a sample script that posted elsewhere and what I used to test this out successfully:

            Set Variable [ $FileName ; Value: "Test_" & Substitute ( Get ( CurrentDate ) ; "/" ; "-" ) & ".pdf" ]
            Save Records as PDF [ No dialog ; "$FileName" ; Records being browsed ]
            Set Variable [ $PDFPath ; Value: Get (DocumentsPath) & $FileName ]
            Send Mail [ Send via E-mail Client ; To: "user1@abc.com" ; Subject: "Invoice" ; Message: "Test" ; "$PDFPath" ]

            Run this script in FileMaker Go and see if this works.  If so, then slowly start adding some of your other options (CC, BCC, Document Compatibility, etc.).  It is possible you have uncovered a combination of options that may not work.

            If it is not saving the file on Windows, you may want to set a dummy field to "Get (DocumentsPath)" to confirm.  Then build on that.

            TSGal
            FileMaker, Inc.

            • 3. Re: Emailing Multi Page Emails
              DennyHayes

              Okay, I tried your script. I just printed the script as a pdf file and and copy/pasted it here to make sure there are no mistakes. I know that developers here have mentioned that it works, but I am curious if any have sent multiple pages? This file is hosted in the MacUSA.com server, in the midwest, so that all of my sales people can access it. It is cheaper than trying to maintain it on my company server.

              1. Set Variable [ $FileName; Value:"test_" & Substitute ( Get ( CurrentDate ) ; "/" ; "-" ) & ".pdf" ] 
              2. Save Records as PDF [ File Name: “filemac:/G5 1 HD 1/Users/dennyhayes/Documents/$FileName”; Records being browsed ] 
              3.    [ Document -  Compatibility: Acrobat 5 and later ] 
              4.    [ Pages -  Number Pages From: 1; Include: All pages ] 
              5.    [ Security -  Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ] 
              6.    [ Initial View -  Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ] 
              7.    [ Restore; No dialog ] 
              8. Set Variable [ $PDFPath; Value:Get (DocumentsPath) & $FileName ] 
              9. Send Mail [ Send via E-mail Client; To: "denny@sotae.com"; Subject: "Invoice"; Message: "Test"; Attachment: “$PDFPath” ] 

               But here is what really happens:

              On a Mac Pro running OS 10.4.11 the script saves the pdf file in the user documents folder with the name "$FileName.pdf", instead of the name, with the date, that you would expect. I understand that you tried to add the date, so that the file being saved twice would not have a conflict. BTW, in my original script, that I posted a couple days ago, I also included the time as well as the date, because, as someone mentioned, you could send the same file a few times per day. I actually did it like this "100930-1032 Quotation Q6753467" I sometimes also included the customers name. The days of the 8 plus 3 file names are history :) But using your script, when the file is sent via email it does come with the name "test_10-1-2010.pdf" as you would expect. It just doesn't save it with that name, in the documents folder, for some reason. Also, the emailed pdf file is received properly with all three pages.

               But sending it from Filemaker Go is a different story. The file is saved in the documents folder with the expected name, and file name in the received email is also correct "test_10-1-2010.pdf". but only one page is in the iPhone documents folder, and only one page is received via email.

               Running the same script on a PC, with the XP Pro OS gives you the message "test_10-1-2010.pdf could not be created on this disk. Use a different name, make more room on the dick, unlock it or use a different disk". I haven't tried sending it on a newer PC OS, because at the moment those computers are being used. But I will try it on one of them later. Many PC users are still using XP Pro, so it should work with that OS. I am assuming that the Get (DocumentsPath) is not returning the proper path on the PC. I know that the PCs typically use back slashes instead of forward slashes to separate the path sections, but I tried changing them, and it still doesn't work.

              • 4. Re: Emailing Multi Page Emails
                TSGal

                DennyHayes:

                Thank you for the additional information.

                In your second step, you have the $FileName within the quotes, so it will save the file as $FileName.pdf.  Instead, it should read:

                Save Records as PDF [ File Name: "filemac:g5 1 HD 1/Users/dennyhayes/Documents/" & $Filename ; Records being browsed ]

                Since my simple script is not working for you, I would like to see your database file so I can try to reproduce.  Check your Inbox at the top of this page for instructions where to send the file.

                TSGal
                FileMaker, Inc.

                • 5. Re: Emailing Multi Page Emails
                  DennyHayes

                  It is Filemaker that is adding the quotation marks. Here is what is typed into the Specify Output File window > 

                  filemac:/G5 1 HD 1/Users/dennyhayes/Documents/$FileName. But when you print that script out as a PDF, you don't see the whole string and there are quotation marks. Here, I will try to add an image. 

                  • 6. Re: Emailing Multi Page Emails
                    DennyHayes

                    Interesting.... I could not paste an image here. I tried pasting from Word, and it appeared, but would not insert. If I remember right I did that some way by finding it on my desktop and sending it. There are two icons on the left that are grayed out, and I am not sure if those were the ones, or why they are grayed out.