1 Reply Latest reply on Jun 22, 2015 8:27 AM by davidanders

    Applescript Help!

    AndrewJudd

      Title

      Applescript Help!

      Post

      Hi all, I'm working on an applescript that is at the end of a filemaker script that exports a container field in a foundset to the desktop. I'd like a user to be able to click a button which exports the images to the desktop, opens a new email with Mac Mail and then opens a dialog box where the user can simply click and add the newly exported images to the newly made email.

      I'm almost there with it. I'll include the script and the applescript below.

      I get the error codes "The variable themessage is not defined" and then "unknown error - 2753" after the email has been created and you have clicked the attachments to add to the email.

      Any ideas??

       

      tell application "Mail"
      set frontWindow to window
      set newMessage to make new outgoing message
      tell newMessage
      set theAttachment to choose file with multiple selections allowed
      make new attachment at theMessage
      end tell
      end tell

      Screen_Shot_2015-06-19_at_22.27.10.png

        • 1. Re: Applescript Help!
          davidanders

          from a Google "osx mail app applescript new messge add attachment"

          http://www.mactech.com/articles/mactech/Vol.21/21.09/ScriptingMail/index.html

          Adding an Attachment to an Outgoing Message

          You may have noticed in the previous examples that, when creating a new message, a reference to the new message is returned as the result of the make command. Like any result, this reference can be placed into a variable, allowing you to continue referring to the new message.

          One example of when this may be beneficial is when you want to insert an attachment into an outgoing message. In Mail, an attachment is not actually considered an element of a message. Rather, it is considered an element of the content of a message. Therefore, to insert an attachment into a message, you must tell the message to make an attachment within its content. The following example code demonstrates this process.

          set theAttachment to choose file
          tell application "Mail"
             set theMessage to make new outgoing message with properties {visible:true, 
             subject:"My Subject", content:"My Body"}
             tell content of theMessage
                make new attachment with properties {file name:theAttachment} at after last paragraph
             end tell
          end tell