I need an AppleScript script that can run in the background which will send an HTML message using a custom designed template for Apple Mail's built-in stationary when certain specific rules are met.
The script should perform the following steps:
1) If Mail's rule? determine? that the incoming e-mail meets the requirements, the script is executed.
2) The script gets the sender's e-mail address from the incoming e-mail.
3) The script creates a new outgoing message containing the custom HTML stationary
4) The script sends the e-mail.
## Deliverables
This is as far as I've been able to get with the script. I've been running it from Script Editor, so I haven't tested whether the first part of the script will function correctly when executed by Mail's rules.
tell application "Mail"
? ? set theMessage to selection
? ? set the thisMessage to item 1 of the theMessage
? ? set theSender to sender of the thisMessage
? ? set theAddress to extract address from theSender
? ? set sendAgain to 1st message of sent mailbox whose id is 343445
? ? -- Need to tell Mail to Send Again the message sendAgain
? ? set sender of (message sendAgain) to theAddress
? ? send sendAgain
end tell
Using AppleScript, I don't know how to create an HTML e-mail or select a specific stationary, so I thought maybe I could select a previously-sent message and tell mail to send it again to a different address.
I'm waiting for the designer to complete the actual images that should be embedded in the e-mail, so in the meantime, I'm using the attached Mail stationary in its place.
The script must run in the background. It cannot tell Mail to activate.