I am new to applescript, but have set up the following script paired with a mail rule. Its working with exception of the responding mail just opening but not going out, unless I click send manually.
tell application “Mail”
set theSignatureName to “MySignature”
set theMessages to the selected messages of the front message viewer
set theMessage to first item of theMessages
set theOutgoingMessage to reply theMessage with opening window
set message signature of theOutgoingMessage to signature theSignatureName
set sender of theOutgoingMessage to “MyAccount”
send
end tell
tell application "Mail"
set theSignatureName to "MySignature"
set theMessages to the selected messages of the front message viewer
set theMessage to first item of theMessages
set theOutgoingMessage to reply theMessage with opening window
--set message signature of theOutgoingMessage to signature theSignatureName # DISABLED because it issue an error
set sender of theOutgoingMessage to "MyAccount"
send theOutgoingMessage # EDITED
end tell
Above, the account id is deliberately modified.
The signature attached to myAccount is automatically inserted in the message although it’s not asked by the script.
When I run the script posted in the thread which I reported, I get :
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 “”
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
set sender of newMessage to “admin@x.es”
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
When I tested it, the code wasn’t wrapped in the mail rule handler.
Everything worked except the instruction trying to use a given rule.
More, the problem with the named feature is described elsewhere.
Maybe, but I’m skeptical, wrapping the code in the handler was intercepting the error without reporting it.
The Mail’s Applescript dictionary states:
[format]message‚n : An email message
elements
contains bcc recipients, cc recipients, recipients, to recipients, headers, mail attachments; contained by message viewers, mailboxes.
properties
id (integer, r/o) : The unique identifier of the message.
all headers (text, r/o) : All the headers of the message
background color (blue/Œgray/Œgreen/Œnone/Œorange/Œother/Œpurple/Œred/Œyellow) : The background color of the message
mailbox (mailbox) : The mailbox in which this message is filed
content (rich text, r/o) : Contents of an email message
date received (date, r/o) : The date a message was received
date sent (date, r/o) : The date a message was sent
deleted status (boolean) : Indicates whether the message is deleted or not
flagged status (boolean) : Indicates whether the message is flagged or not
flag index (integer) : The flag on the message, or -1 if the message is not flagged
junk mail status (boolean) : Indicates whether the message has been marked junk or evaluated to be junk by the junk mail filter.
read status (boolean) : Indicates whether the message is read or not
message id (text, r/o) : The unique message ID string
source (text, r/o) : Raw source of the message
reply to (text, r/o) : The address that replies should be sent to
message size (integer, r/o) : The size (in bytes) of a message
sender (text, r/o) : The sender of the message
subject (text, r/o) : The subject of the message
was forwarded (boolean, r/o) : Indicates whether the message was forwarded or not
was redirected (boolean, r/o) : Indicates whether the message was redirected or not
was replied to (boolean, r/o) : Indicates whether the message was replied to or not
responds to[/format]
So you must ask the message for its reply to property.