Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is my WIP, I'm posting it now incase I never finish it. Hopefully I'll update this with an example that reads the required fields, rather than being hardcoded.</p> <p>(3rd and probably final update)</p> <p>Apologies if this doesn't do exactly what you need, but it did exactly what I needed, and I believe you requirements are simpler than mine.</p> <pre><code>-- Reply to current message with additional header changes. -- (To be triggered from Keyboard Maestro, or ControllerMate on Alt-R) -- function to read/focus/change data in message field -- usage: set fieldValue to message_field("reply_to", false) -- message_field("reply to", "moron") on message_field(fieldname, newValue) local tElements, tElement, tField, tValue, tClass tell application "System Events" tell process "Mail" set frontmost to true set tElements to scroll areas of window 1 repeat with tElement in tElements set tName to get name of tElement as string try set tField to text field 1 of tElement ignoring white space and punctuation if (name of tField as string = fieldname) then try set tValue to get value of tField as string on error set tValue to "" end try set focused of tField to true if (newValue ≠ false) then set value of tField to newValue -- as string end if exit repeat end if end ignoring end try end repeat end tell end tell return tValue end message_field -- split function (julifos @ macscripter.net) to split(someText, delimiter) set AppleScript's text item delimiters to delimiter set someText to someText's text items set AppleScript's text item delimiters to {""} --&gt; restore delimiters to default value return someText end split -- Get information from current/selected message tell application "Mail" set theSignatureName to "Signature #1" set theMessages to the selected messages of the front message viewer set theMessage to first item of theMessages -- Get the email address (ours, hopefully) the message was sent to set theMessageWasTo to address of first to recipient of theMessage as string -- Unfortunately, it seesm that Mail doesn't honour the existing Reply-To header -- when a reply is triggered from a script, instead of from the Reply menu. -- So here is a bit of a dance to get it. set theMessageHeaders to headers of theMessage try set theMessageReplyToWas to first item of {reply to} of theMessage -- (thx to Brian Christmas) tell me to set theMessageReplyToWas to item 1 of split(theMessageReplyToWas, ",") on error set theMessageReplyToWas to sender of theMessage end try -- you can also use: set temp to {deleted status, all headers, was replied to, flag index, date received, message id, background color, subject, read status, flagged status, message size, date sent, junk mail status, source, sender, was forwarded, was redirected, content} of foo -- set Theheaders to all headers of theMessage -- If you want to get all the headers in text form and process manually -- set mySource to source of theMessage -- If you want the message source set theOutgoingMessage to reply theMessage with opening window -- I want to set "Reply-To" to be the address the message was sent to tell me to message_field("reply to", theMessageWasTo) tell theOutgoingMessage -- I don't like this, as it adds an extra recipient make new to recipient with properties {address:theMessageWasTo} -- so I'll do it my way tell me to message_field("to", theMessageWasTo) end tell -- It's easier if you just want to change the sender or signature or something -- set message signature of theOutgoingMessage to signature theSignatureName -- set sender of theOutgoingMessage to "Federico Viticci " end tell -- Now all that remains is to set the focus back to the body of the message. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload