0

I have been looking up for the last two days and found a few applescripts that claimed to change the subject lines. But none of them seem to be able to change/set the subject line. What do you guys think the mistake is here?

tell application "Mail"
    set theSubjectList to {}
    set themessages to selection as list
    repeat with msg in themessages
        set thisSubject to (subject of msg as string)
        if thisSubject is not in theSubjectList then
            set theSubjectList to theSubjectList & {thisSubject}
        end if
    end repeat

    set theNewSubject to ¬
        (choose from list theSubjectList with prompt ¬
            "Choose the subject of the merged thread…") as string

    if theNewSubject is in theSubjectList then
        repeat with msg in themessages
            set subject of msg to (theNewSubject)
        end repeat
    else
        display dialog "Action cancelled"
    end if
end tell

I get the following error

error "Mail got an error: Can’t set subject of message to \"CHANGED SUBJECT LINE\"." number -10006 from subject of message
  • None of the scripts were actually updated for the latest Mac/Mail.app version. Do you people think this function may be deprecated? – Harish Prasanna Sep 2 '15 at 18:13
1

The simple answer is that "subject" is read-only. Mail's Applescript dictionary shows:

subject (text, r/o) : The subject of the message

I would love to be able to combine messages into a thread, but I can't see how to change the subject without perhaps exporting and re-importing messages.

  • Yep Charles. I ended up creating a python program to do it. So now the Automator python app can take .eml files as input and change the subject and save back to the same .eml file which I import back to the mailbox. – Harish Prasanna Oct 2 '15 at 21:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .