Mail autoreply with attachment

Hi, I have a script to autoreply in Mail which works great. However, I can’t figure out how to add to the script to include an attachment in the reply email…can any one help?

This is the current script I have:

Code:

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			repeat with eachMessage in theMessages
				set theName to extract name from sender of eachMessage
				if exists reply to of eachMessage then
					set theAddress to reply to of eachMessage
				else
					set theAddress to extract address from sender of eachMessage
				end if
				set newMessage to make new outgoing message
				tell newMessage
					make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
					set visible to false
					set subject to "Re: " & subject of eachMessage
					set content to "Thanks for applying for this weeks competition, please find the quiz sheet attached."
				end tell
				send newMessage
				tell eachMessage
					set was replied to to true
				end tell
			end repeat
		end tell
	end perform mail action with messages
end using terms from

Hi,

insert this line as last line within the tell newMessage block:

tell content to make new attachment with properties {file name:theAttachment} at after the last paragraph

Note: theAttachment should be an alias

Thanks Stefan…however (please forgive my noob-ness) how do I define the filename? Do I need to write the whole path? And where should I put the alias?

Thanks,

Dom

Hi Dom,

the file name is a path, for example:

set theAttachment to (((path to desktop) as string) & "myFile.jpg) as alias

or just:

set theAttachment to (choose file without invisibles)