I know almost zilch about AS. I need a simple (or I assume it’s simple … ) script (or maybe two scripts?) to either create a new outgoing message or a reply to an incoming message, with a background colour set (say, orange). This is so I can then set a Mail rule to and/or a Hazel rule to move/copy the new message/reply to a particular user mailbox.
I’ve tried this:
tell application "Mail"
set newMessage to make new outgoing message
tell newMessage
set background color to orange
end tell
end tell
but I get an error … and I’ve reached the limit of my measly understanding. Help appreciated. Thanks.
This will get you the message you want, and it should address the message, but I get an error saying newMessage is undefined.
set x to quoted form of "<html>
<body bgcolor=\"#ff8000\">
<p>
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.
</p>
<p>
This is another paragraph. This is another paragraph. This is another paragraph. This is another paragraph.
</p>
</body>
</html>"
do shell script "echo " & x & " > ~/desktop/testtext.html"
set pth to (path to desktop folder as text) & "testtext.html" as alias
tell application "Safari"
activate
open pth
tell application "System Events"
keystroke "i" using {command down}
end tell
end tell
tell application "Mail"
activate
delay 0.5
set newMessage to (outgoing message 1) as alias
tell newMessage
make new recipient at end of recipients of newMessage with properties {address:"xxx@xxx.com.au"}
end tell
end tell
do shell script "rm ~/desktop/testtext.html"