All I get is a list of items (in my case 36) that each have a value of “missing value”
-- Lets assume we have selected a message or messages in Apple Mail.
tell application "Mail"
set MessageList to selection
set MessageItem to item 1 of MessageList
set MessageHeader to (get all headers of MessageItem)
end tell
Does anyboby know why this apparently simple script fails to read the message headers?
All the properties of the header sub-classes return a “-1728” error, which I think is an AppleEvent error.
set messageList to selected messages of message viewer 1
Thanks for the reply.
Tried your solution and still get “Error getting content: -1728” and “Error getting name: -1728”. “content” and “name” being the 2 properties of the header sub-class.
All of the headers are identified within the header class but the various sub-classes all have this “Error getting ” issue.
Try:
set MessageHeader to (get every header of MessageItem)
Still no luck. Same result.
https://dl.dropbox.com/u/27463133/Screen%20Shot%202012-07-10%20at%2010.05.15[X].png
Here is a screenshot of what I get, I’m using ScriptDebugger 5.
No help, I’m afraid, but I get exactly the same sort of response in Script Debugger 5.0 running under Lion on my iMac. I think it’s a problem with Mail.
Thanks for the response.
I’ve search the Internet for an answer but no-one seems to know. Any info usually relates to not being able to get it to work. I’ve found no definitive statement that it is broken as opposed to us simply not implementing it properly.
Thank you for your help, efforts and all your responses. They are very much appreciated.
What is it you want to get from the headers? Perhaps there’s another way.
Ultimately I have been looking into the Apple Mail conversations and why such a great idea fails to work. The rules that govern conversations seem to be very specific and totally inflexible. I mean if another person joins your “conversation” there is no way to add them in, Mail just blindly starts a second conversation… Even though it is the same “topic”, not that Mail can know it is the same topic but there is no way of letting mail know.
One of the message headers is “References” and this contains a list of message ids for all “related messages”. View the email source and you will see "Message-Id: " and "References: ". References and Message-Id “appear” to be the criteria Apple Mail uses to associate messages into a conversation. Or one method atleast. As the message chain lengthens the number of message ids in the references header increases.
I believe that a conversation is made up of all the messages in the References header plus the current message. This is now Apple Mail defines a 'conversation".
So logic would dictate that being able to update this “References” header would enable you to add a new message into your “conversation”. Any replies to the incoming message would then include the new associated email in its references header and Apple Mail would thereafter include the new message in the “conversation”.
Unfortunately logic and technical possibilities seem to be light years apart.
Wouldn’t it be great to have a little script, or an inbox rule, to associate new messages into existing tidy conversations. I mean conversations is a really cool feature for keeping related messages together “as long as it is a reply to a message of the conversation OR has the identical subject line”.
There must be a reason why this is proving to be so difficult and it would be great to know.
Thank you for all the help and the replies.