Auto reply to email with rich text mail

I have been trying and searching for days for a simple method to do this to no avail so I'll ask here in the hope someone has a way to do this.

Basically I want to have Apple mail app run a rule that automatically replies to certain emails it receives. Simple so far!

The difficulty I'm having is that I want the email reply to be in rich text as it contains a number of links for documents that the user should then download. Unfortunately the inbuilt reply option only seems to allow plain text which is not much use and I don't want to add the full urls in the message or rely on users copying pasting etc.

I've tried automater and applescript but with little success. I thought this would be really easy but its left me confounded at the difficulty!

Anyone out there got any tips or ideas on this??

PB G4 1.67ghz (1.5gb 120gb) G5 dual 1.8ghz (1gb ram 1TB), Mac OS X (10.4.9), BW G3 333, G3 imac, emac, nano, 360, Wii, Dell (various)

Posted on Nov 23, 2010 5:07 PM

Reply
9 replies

Nov 24, 2010 5:46 AM in response to 4pack

Here's a very simple way of doing what you are asking for, if only you don't mind using [GUI Scripting|http://www.macosxautomation.com/applescript/uiscripting/index.html]. Set up a rule in Mail to trigger the following script, which should then automatically reply to each appropriate incoming message by pasting into the corresponding outgoing message the rich text content of a TextEdit document saved as "AutoReply.rtf" on your Desktop (although the location of that file can easily be changed).

I have commented out the line “send” (in green below) so that you can test the script without actually sending any message.

*using terms from application "Mail"*
* on perform mail action with messages theMessages for rule theRule*
* set theFile to alias (((path to home folder) as text) & "Desktop:AutoReply.rtf")*
try
--Copy the content of the TextEdit document to the clipboard:
* tell application "TextEdit"*
* open theFile*
* delay 0.5*
activate
* tell application "System Events"*
* keystroke "a" using command down* -- select all
* keystroke "c" using command down* -- copy
* end tell*
* close front document*
* end tell*
--Reply with Mail:
* tell application "Mail"*
* repeat with eachMessage in theMessages*
* set newMessage to reply eachMessage with opening window*
* tell newMessage*
* set visible to true*
* delay 0.5*
activate
--Paste the content of the clipboard into the current message:
* tell application "System Events"*
* keystroke "v" using command down*
* keystroke return & return*
* end tell*
* delay 0.5*
--send -- send the current message
* end tell*
* end repeat*
* end tell*
* end try*
* end perform mail action with messages*
*end using terms from*



Let me know if anything doesn't work as expected (this is only a beta version 😉 )

Message was edited by: Pierre L. (nothing essential)

Nov 24, 2010 9:11 AM in response to Pierre L.

Looking deeper it seems that scripting rules in mail are broken in 10.5.x

http://discussions.apple.com/thread.jspa?threadID=1226817&start=0&tstart=0

As 10.5 has been surpassed and my G4 powerbook is considered obsolete by the powers that be (so no 10.6 for me) looks like I'll have to work around it.

I have tried some other scripts that should work and it seems that mail ignores it...

How does something so simple become so difficult 😟 I tried hacking the messagerules.plist and inserting the rtf code into the relevant spot as an easy cheat but it still blew it out as plain text.

Thx for your help tho most appreciated 🙂

Message was edited by: 4pack

Nov 25, 2010 10:10 AM in response to 4pack

4pack wrote:
Ah b **ks to it. Unbelievably this is just too much like hard work...


Not sure what your script looks like, but this auto-reply script (set up as a Mail Rule) replies in Rich Text (from http://macscripter.net/viewtopic.php?id=34041) :

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #E6E6EE;
overflow: auto;"
title="this text can be pasted into the AppleScript Editor">
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with thisMessage in theMessages
set theName to extract name from sender of thisMessage
if exists reply to of thisMessage then
set theAddress to reply to of thisMessage
else
set theAddress to extract address from sender of thisMessage
end if
set theNewMessage to make new outgoing message
tell theNewMessage
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 thisMessage & "- Change of address"
set sender to "My Name <myusername@mydomain.com>"
set content to "Dear " & theName & ",

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 myoldusername@myolddomain.com with my new address mynewusername@mynewdomain.com .

Thankyou,
Me"
end tell
delay 5
send theNewMessage
tell thisMessage
set was replied to to true
end tell


end repeat
end tell
end perform mail action with messages
end using terms from</pre>

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Auto reply to email with rich text mail

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.