Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript / Automator help - attach PDF to e-mail then move to folder location

Hello,


Could anybody put a script together for the following (quick action)? It would be extremely helpful for my daily life.


  1. Attach PDF file to an outgoing e-mail
  2. Allow space for me to enter the recipient's address in the Automator/AppleScript (this changes often)
  3. Create subject as the file name
  4. Move the PDF to a local folder on my MacBook


Bonus point - This is not absolutely necessary, but if I was able to add the case name and date to a new line on a pages file then I would have an automatic record of all my sent invoices. I would love you forever if you could add this.


I am very grateful in advance for your help.

Posted on Sep 19, 2021 7:38 AM

Reply

Similar questions

3 replies

Sep 20, 2021 1:51 PM in response to smh9321

At a high level, what you ask isn't hard, but there are some missing bits.


For example, you say "Attach PDF file to an outgoing e-mail". Where does this email come from? Have you already created the email and you're trying to add a PDF to it? Or do you want the script to make the email?


Also, you say you're looking for a 'quick action', this implies that you intend/expect to initiate this from the Finder, presumably by ctrl-clicking on the .PDF file and having the script respond.


Also, "Allow space for me to enter the recipient's address in the Automator/AppleScript"

What do you mean by this? Are you assuming the script will fill in the recipient's email address? Where do you expect this to come from?


As a starting point, this script added as part of a 'Run AppleScript' action should get you in the right direction, but as I said above, there are some gaps in understanding how you expect this to work.


on run {input, parameters}
	
	set theFile to item 1 of input
	tell application "System Events" to set theFileName to name of (get properties of theFile)
	tell application "Mail"
		set newMsg to make new outgoing message
		tell newMsg
			set subject to theFileName
			make new attachment at end of attachments with properties {file name:theFile}
			make new to recipient with properties {name:"John Smith", address:"johnsmith@nowhere.org"}
		end tell
	end tell
	
	-- ask the Finder to move the file. Change the destination path as preferred
	tell application "Finder"
		move file theFile to (path to documents folder)
	end tell
	return input
end run





Sep 22, 2021 5:57 AM in response to Camelot

Camelot, firstly thank you for your help thus far.


In effect what i’m trying to do it right click pdf files on my desktop, then quick action to create new e-mail, and add this file to the e-mail and use the filename as subject.


Once I have the quick action set up I can duplicate it and change the addressee in each workflow, so the addressee’s e-mail address will come from the workflow its self.


For context, I produce PDF case reports and send them to ten or eleven different firms. But the process is always the same. So i’ll duplicate the workflow for each firm.


I then move the same PDF from the desktop into a folder for that firm in dropbox (local folder).


Thanks again

AppleScript / Automator help - attach PDF to e-mail then move to folder location

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.