Niel (or anyone else willing to help me!),
I wonder if you could help me again. I'm doing a similar thing as above, but this time, I need to:
1. select a random photo (or file) from a folder
2. put it into an *already open* email at the bottom as an attachment
-----
I found the following script online, and it works great. However, it creates a NEW email message and fills in fields. For my use, I need to remove most of the lines so that it doesn't create a new email but instead just uses the email window that is already open. I don't need it to fill in any of the fields. I need it only to attach the photo at the end.
I've tried taking out most of the lines, but I can't get it to work. Can you please help?
Thanks very much! 🙂
David
-----
tell application "Finder"
--- set the exact path of your folder of files (could be photos, pdfs, a mixture of types)
set random_file to some file of folder "MyMac:Users:david:Desktop:PhotoCollection"
end tell
--- change the following variables to anything you want
set theSubject to "new subject"
set theBody to "this is the message body"
set theSender to "Joe"
set theName to "Bill"
set theAddress to "email@domain.com"
set theAttachment to random_file
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
tell newMessage
set visible to true
set sender to theSender
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
tell content
make new attachment with properties {file name:random_file as alias} at after the last paragraph
end tell
end tell
activate
--- uncomment the next line if you want it to automatically send this email!
--- send newMessage
end tell
-----