Saturday, November 18, 2017
  • Index
  •  » Automator
  •  » Passing a file to applescript in an variable

#1 2015-10-05 03:26:26 pm

dobunzli
Member
Registered: 2015-10-05
Posts: 2

Passing a file to applescript in an variable

Hello,
I would like to create an application that will take a pdf as input (drag and drop) and sends an email with a user choosen subject.

I have thus created an automator workflow that is almost working. The only part I am not getting is passing the dropped file to the applescript so that it will attach it within the mail

Can someone help me to sort this out ?

Thanks in advance for your help !

Here you can download the zipped workflow
http://s000.tinyupload.com/index.php?fi … 1398698508

and here is the applescript at the end of the automator workflow. The problem has to do with passing the second item of input.

on run {input, parameters}

    set theSubject to first item of input -- the subject
    set myFiles to second item of input -- the file

    set theContent to "" -- the content
    set theAddress to "xxx@163.com" -- the receiver
    set theAttachmentFile to myFiles
   
    tell application "Mail"
        set msg to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
        tell msg to make new to recipient at end of every to recipient with properties {address:theAddress}
        tell msg to make new attachment with properties {file name:theAttachmentFile as alias}
        send msg
    end tell
   
end run

Offline

 

#2 2015-10-07 01:25:29 am

dobunzli
Member
Registered: 2015-10-05
Posts: 2

Re: Passing a file to applescript in an variable

Hello,
Here is the answer:

Input parameter in the script contains a list of all variables from the previous Automator Actions "Get variable", in the same order. but you need to make sure you only get the list of variables you're looking for. In your current Automator flow, select the action "get value of No_Fax" and select "ignore entry". then the flow will stack only No_Fax and Files in the input parameter. Item 1 of input will be No_Fax, item 2 will be the 1st file, item 3, the 2nd file ....


from here http://stackoverflow.com/questions/3297 … pplescript

Offline

 
  • Index
  •  » Automator
  •  » Passing a file to applescript in an variable

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)