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

OSX Automator send file as attachment in email

I've followed all the steps here:


https://discussions.apple.com/thread/252272638?login=true


and it looks the same as the example, and the workflow runs without errors, but it's not attaching the file. Everything else works fine. What am I missing?


Thank you!

iMac Line (2012 and Later)

Posted on Dec 29, 2021 3:15 PM

Reply
Question marked as Best reply

Posted on Dec 30, 2021 12:08 PM

buzzjackson wrote:

What am I missing?


Hard to know without looking over your shoulder, checking exactly what you've done and comparing it with the original suggestion.


That said though, I can't see how the original workflow ever created an email with attachments, as it doesn't appear to pass references to the selected pdfs to the New Mail Message action.


The following may work better. I've omitted the action that moves the selected PDFs to the Downloads folder - you could re-instate it if you wanted to.


My workflow would run like this (six steps, numbered in the screen grabs).


  • Quick Action Workflow receives current PDF files in Finder.
  • First action: Set Value of Variable - I set the variable name to Attachments. This stores the file references for later.
  • Second action: Run AppleScript - exactly the same as in the original, this extracts the names of the attachments for the email's subject line.
  • Third action: Set Value of Variable - I set the variable name to Filename. Stores the the values output from the AppleScript.
  • Fourth action: Get Value of Variable. I set the variable name to Attachments. This picks up the file references for use as attachments. In the Options for this action, check Ignore this action's input. There should be no flow arrow connecting the previous Set Value... action with this Get Value... action.
  • Fifth action: New Mail Message. The file references from the fourth action will be passed to the email message as attachments. In the subject line, drag in the Filename variable from the list at the bottom of the workflow.


The screen grabs hopefully illustrate this. Step 4 is duplicated to show the join:







You would need to add a Send Outgoing Messages action at the end if you wanted the email to be sent automatically.


For reference, this is the original, unedited, AppleScript (not quite how I would have done it):


on run {input, parameters}
	set subjectInfo to {}
	tell application "Finder"
		repeat with oneFile in input
			copy name of oneFile to end of subjectInfo
		end repeat
	end tell
	set AppleScript's text item delimiters to {", "}
	return text items of subjectInfo as text
end run


Cheers,


H






Similar questions

4 replies
Question marked as Best reply

Dec 30, 2021 12:08 PM in response to buzzjackson

buzzjackson wrote:

What am I missing?


Hard to know without looking over your shoulder, checking exactly what you've done and comparing it with the original suggestion.


That said though, I can't see how the original workflow ever created an email with attachments, as it doesn't appear to pass references to the selected pdfs to the New Mail Message action.


The following may work better. I've omitted the action that moves the selected PDFs to the Downloads folder - you could re-instate it if you wanted to.


My workflow would run like this (six steps, numbered in the screen grabs).


  • Quick Action Workflow receives current PDF files in Finder.
  • First action: Set Value of Variable - I set the variable name to Attachments. This stores the file references for later.
  • Second action: Run AppleScript - exactly the same as in the original, this extracts the names of the attachments for the email's subject line.
  • Third action: Set Value of Variable - I set the variable name to Filename. Stores the the values output from the AppleScript.
  • Fourth action: Get Value of Variable. I set the variable name to Attachments. This picks up the file references for use as attachments. In the Options for this action, check Ignore this action's input. There should be no flow arrow connecting the previous Set Value... action with this Get Value... action.
  • Fifth action: New Mail Message. The file references from the fourth action will be passed to the email message as attachments. In the subject line, drag in the Filename variable from the list at the bottom of the workflow.


The screen grabs hopefully illustrate this. Step 4 is duplicated to show the join:







You would need to add a Send Outgoing Messages action at the end if you wanted the email to be sent automatically.


For reference, this is the original, unedited, AppleScript (not quite how I would have done it):


on run {input, parameters}
	set subjectInfo to {}
	tell application "Finder"
		repeat with oneFile in input
			copy name of oneFile to end of subjectInfo
		end repeat
	end tell
	set AppleScript's text item delimiters to {", "}
	return text items of subjectInfo as text
end run


Cheers,


H






Dec 30, 2021 2:28 PM in response to HD

And finally...


An Automator Quick Action that does the same thing using just a Run AppleScript action:


on run {thefiles}
	set TheSender to "someone@icloud.com"
	set TheReceiver to "someone.else@gmail.com"
	set theContent to "Here are your files, buddy!" & return
	set subjectline to ""
	tell application "Mail"
		activate
		set nuMessage to (make new outgoing message at end of outgoing messages with properties {sender:TheSender, content:theContent})
		tell nuMessage
			make new to recipient at end of to recipients with properties {address:TheReceiver}
			repeat with eachfile in thefiles
				set eachfile to eachfile as alias
				make new attachment at end of paragraphs with properties {file name:eachfile}
				tell application "System Events" to set subjectline to subjectline & name of eachfile & ", "
			end repeat
			set subjectline to rich text 1 thru -3 of subjectline
			set subject to subjectline
		end tell
	end tell
end run



That's all folks...



Dec 30, 2021 12:42 PM in response to buzzjackson

Glad it worked, thanks for the feedback 😊


FWIW here's my version of the AppleScript - same result but slightly simpler:


on run {thefiles}
	set subjectline to ""
	repeat with eachfile in thefiles
		tell application "System Events" to set subjectline to subjectline & name of eachfile & ", "
	end repeat
	set subjectline to text 1 thru -3 of subjectline -- remove final ", "
	return subjectline
end run


OSX Automator send file as attachment in email

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