Hi All - Can someone please help me?
After a lot of searching I found two scrips that partially cover what I need (when run separately) covering most of what I am hoping to achieve. My zero coding skills has resulted in a couple of weeks trying to learn Applescript in my limited spare time, to combine the two versions, without success!
I am truly grateful for your time, and assistance, in helping me with my quest.
The requirement is to take an image (always a single image) and use Automator to run the process once dropped into a watched folder.
When the image is dropped onto the Mail Droplet in the watched folder it should load a new Mail message, populate the To, Cc and Bcc fields (if populated), set the senders account, insert the name of the file as the Subject, minus its extension, insert the image, and populate a short line of text as the body of message above the image. No Signature is used or required.
I have inserted comments in the version of the script below, which does most of what I am looking to achieve, along with a copy of the other script, which does insert the name of the file, but errors on doing so, and does not populate and Mail details. The code may still have some of my botched attempts to combine, so please forgive. The other version is pretty much untouched.
Below is a screenshot of the error message for reference, and a screenshot of a mocked-up version of the Mail Message I would like to achieve, with notes where things are working, or not quite working.
In addition I would like to sequentially change the email bodymessage, which is also covered in the notes of the script below. This is because my son will be sending the files for media usage, and the message line will be used for the image supplied as part of the post. I would be happy to either hard code a selection (ideally without a limit) of messages to be used into the code, or an XML file, whichever is best / easiest to maintain.
Once the sequential email body message list is complete the code would start again from the first message. The body message needs to be able to accept # . and @ as shown in the example image, to work with mediums such as twitter.
Please note I have left out the send command from each example, as I wanted time to check everything was working first. If I am correct this is a simple addition once the code is complete - but, I have discovered when coding nothing is as it seems!
The following code works when saved as an Application, and an image is dropped onto it. I have inserted some notes / requirements on the items that are missing or need resolving, or where I simply don’t have the skill to code.
--the following script works, however, it does not have code to include the name of the attachment as the Subject, minus the attachments extension
--the option to use NameOfFile or Fixed subject would be ideal, which would be used by creating more than one version of the code for use with the core code items toggled on or off as required
--ability to insert fixed text such as #TAG after the file name would be useful too
property nameList : {"name1", "name2"}
--nameList works with the code below
property emailList : {"name1@address.com", "name2@address.com"}
--emailList works with this code
--Property CcList : {"CcName@address.com"}
--not configured, as do not know how to include this in the code. Please help
--property bccList : {"Bccname@address.com"}
--not sure if Bcc format is correct, and it is not included in the code below. Please help
property myaccount : "John Doe <john@doe.com>"
--code fails with error message if this is marked out
--comfortable leaving in to minimise code changes as will only use one account anyway
property theSubject : "Subject with File Name. Or file name and #Tags, or just text"
--works when using fixed text!
--code desired needs to insert file name of the file, or fixed text, or a mix of fixed text and the file name. for example. Updated Image: NameOfFle, which will change based on what is entered
property EmailBody : ".@names_of_name body message including . and @ for social media needs."
--works with code below as fixed text entry
--looking for an ability to have sequential body text with ideally no limit. Required for events where a new message needs to be attached to the post for social media posting.
--similar to random quotes only sequential
on run
tell application "Finder"
set sel to (get selection)
end tell
new_mail(sel)
end run
on open droppedFiles
new_mail(droppedFiles)
end open
on new_mail(theFiles)
tell application "Mail"
set newMessage to make new outgoing message with properties {visible:true, subject:theSubject, content:EmailBody}
tell newMessage
set sender to myaccount
repeat with i from 1 to count nameList
make new to recipient at end of to recipients with properties {name:item i of nameList, address:item i of emailList}
end repeat
tell content
repeat with oneFile in theFiles
make new attachment with properties {file name:oneFile as alias} at after the last paragraph
end repeat
end tell
end tell
activate
end tell
end new_mail
The following code inserts the names of the file, but creates and error, and the image attachment is not shown:
on open Dropped_File
tell application "Finder"
set NameOfFile to (name of (info for Dropped_File))
set myFile to Dropped_File as alias
--display dialog NameOfFile
end tell
tell application "Mail"
set mySubject to NameOfFile as rich text
set myContent to "Attached is the latest image from today " & NameOfFile & "Thanks, Prescience"
set myAttachment to Dropped_File
set myMsg to make new outgoing message with properties {subject:mySubject, content:myContent}
tell myMsg
make new attachment with properties {file:myFile}
end tell
open myMsg
end tell
end open
I’ll happily donate to a registered charity of choice for the person that helps me solve this, or to MacScripter.
Image links used for reference images will be deleted once any help provided resolves the request:
Mocked-up image:
Error message image:
Operating system is macOS Sierra 10.12.3