AnsweredAssumed Answered

Embedded Applescript Question

Question asked by edwardlscott on Aug 28, 2018
Latest reply on Aug 29, 2018 by fmp

I've never really gotten much past the "beginner" level with Applescript.  The following script works nicely in the Script Editor to open Google's mail client "MailPlane" and stage an email:

 

tell application "Mailplane"

            set m to make new outgoing message with properties {directlySend:false, optimizeAttachments:true}

            tell m

                        set r to make new to recipient at end

                        tell r

                                    set address to "escott@scott-resources.com"

                                    set name to "Ed"

                        end tell

                        set subject to "My Subject"

                        set content to "My message content is blah blah blah ..."

            end tell

            compose m

end tell

 

I would like to embed the above applescript in a FileMaker script and have it be able to run without errors.  In my FM script, I have a "Set Variable" step that sets $Code to the above code as modified to be a string like this:

 

"tell application \"Mailplane\"

  set m to make new outgoing message with properties {directlySend:false, optimizeAttachments:true}

  tell m

  set r to make new to recipient at end

  tell r

  set address to \"escott@scott_resources.com\"

  set name to \"Ed\"

  end tell

  set subject to \"My Subject\"

  set content to \"My message content is blah blah blah ...\"

  end tell

  compose m

end tell"

 

Then I have a Perform Applescript step configured as a "Calculated AppleScript" that executes $Code.  This produces two errors, 1) Expected end of line but found "set", and 2) Unknown Error: -2741

 

This earlier thread addresses this exact issue: Applescript and Filemaker -- another possible bug

 

However, there isn't quite enough info in the thread to guide me on exactly how to modify my errant script code to work as described within the context my FM script.  Can someone post a modified version of the code above (orange) that would address the problem such that $Code would execute in my FM script? 

 

Thanks in advance,

Ed

Outcomes