Hello everyone
I was hoping for a bit of help creating an Applescript that enables me to send HTML auto response emails in OS X Mail using a Rule. I’m new to Applescript so please excuse my complete lack of knowledge on the subject. I messed around with a few scripts found here on the forum but none of them seemed to work properly.
The following script worked fine but I don’t know how to replace the email “content” with HTML content
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with thisMessage in theMessages
set AppleScript's text item delimiters to {""}
set thisSender to sender of theMessages
set theNewMessage to reply thisMessage with opening window
tell theNewMessage
set fromAccount to account "mynewaccount"
set content to "This is an automated reply. Your message has been forwarded to my new e-mail address. For future reference, please update your records by replacing my former address oldusername@olddomain.com with my new address newusername@newdomain.com .
Thankyou,
Lance"
end tell
send theNewMessage
end repeat
end tell
end perform mail action with messages
end using terms from
I’ve tried this script that I found here - http://jacobsalmela.com/os-x-mail-create-html-formatted-auto-response-applescript-rules/ but I doesn’t seem to work well. It just sends a blank auto response email.
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 customHTML to "<html><body><h1>Thanks</h1><p>for emailing me.</p></body></html>"
set newMessage to make new outgoing message with properties {html content:customHTML}
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
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
I should add that the auto response email I want to send is from an email alias and not from my default email. I found this script on the forum, but again I don’t know how to make it work.
set theAccount to "put-your-account-email-here@mail.com"
set the_mailto to "email@mail.com"
tell application "Mail"
activate
set newMessage to make new outgoing message with properties {sender:theAccount, address:the_mailto}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {address:the_mailto}
end tell
end tell
So is there any way I can magically combine these scripts into one single script that actually works for me? Any help would be highly appreciated.
P.S. I’m got OS X El Capitan 10.11 on my iMac