Attach multiple files in email?

I have a macro that emails the file currently selected in finder. If multiple files are selected, that number of emails is sent, each with one file attached.

Is there a way to have a single email sent with all of the selected files attached?

Current macro:

Since trying to manually attach multiple files (using the folder icon/button) did NOT work, I'm going to guess that the KM Send Mail does NOT support multiple files.

You might be able to workaround this by first creating a zip file of all of your selected files, then attach the zip file.

1 Like

If the macro is being launched from the Finder, this can be done largely by taking advantage of built-in Copy and Paste capabilities. The macro shown

  1. copies the selected files in the Finder;
  2. has AppleScript activate Mail and make a new message;
  3. uses Keyboard Maestro to move to the body of the email and paste the files;
  4. Keyboard Maestro then moves the cursor to the beginning of the message body in case you need to add/change the message;
  5. finally, Keyboard Maestro deletes from the clipboard the files that were copied.

image

Here's the AppleScript which needs some editing for use with your email information and recipient information.

tell application "Mail"
	activate
	set theOutMessage to make new outgoing message with properties {visible:true}
	tell theOutMessage
		make new to recipient at end of to recipients with properties {address:"first@mail.com"}
		set sender to "Name Surname <name.surname@mail.com>"
		set subject to "Message Subject" --optional
		set content to "Message Text" --optional
	end tell
end tell
2 Likes

Nice one, thanks.

If you are going to use an AppleScript, like @NaOH provided, you might as well do the whole job using a script, including attaching the files you have selected in Finder:

tell application "Finder"
  set attachList to selection as alias list
end tell

tell application "Mail"
  activate
  set theOutMessage to make new outgoing message with properties {visible:true}
  tell theOutMessage
    make new to recipient at end of to recipients with properties {address:"first@mail.com"}
    set sender to "Name Surname <name.surname@mail.com>"
    set subject to "Message Subject" --optional
    set content to "Message Text" --optional
    
    repeat with oAttach in attachList
      make new attachment with properties {file name:oAttach}
    end repeat
    
  end tell
end tell
2 Likes