Hi List
In another list I did try to get some answers but unfortunate no reply. Because I am at the end of my knowledge and trials I will place my request here.
It goes about the following:
Lets say, I did do a search in mail and got a nice list of messages.
I see an item that I would like to investigate, but there is only one or two messages from the whole conversation (responses cq threads) in this search result list. But of course I would like to see the whole thread. I do run my script and there I got a new window with my threads only.
I am working in Leopard.
Yesterday I did have some time to put my readings into practice.
I came up with the following.
on run {input, parameters}
tell application "Mail"
activate
set msg to item 1 of (selection as list)
set msgAccount to name of account of mailbox of msg --<-- (4th error)
set msgMailboxname to name of mailbox of msg
set viewer to make new message viewer
--delay 1
tell application "System Events" to tell application process "Mail"
keystroke "m" using {command down, shift down}
end tell
activate
-- test point
--> return selection & {msg} & {msgAccount} & {msgMailboxname} --> in cases 1-3 they are correct here
set selected mailboxes of viewer to {mailbox msgMailboxname of account msgAccount}
delay 0.2
set selected messages of viewer to {msg}
delay 0.3
tell application "System Events" to tell application process "Mail"
keystroke "k" using {command down, shift down}
end tell
set visible messages of viewer to selected messages of viewer --<-- (3th error)
return selection & {msg} & {msgAccount} & {msgMailboxname}
end tell
end run
This does what I want, but eh BUT;
The following problems are arising here,
1). if I choose a smart folder ( with a selection as of today ), select a message, do my thing ( running the script ), it works.
2). if I choose an account in my inbox folder, select a message, do my thing ( running the script ), it works.
3). if I choose the inbox ( top inbox folder), select a message, do my thing ( running the script ), it fails with the following error;
Mail got an error: Can’t set selected messages of message viewer id 256924272 to selected messages of message viewer id 256924272. (6495536)
4). if I choose a mailbox folder , select a message, do my thing ( running the script ), it fails also with the error;
Mail got an error: Can’t get account of mailbox of message id 446115 of mailbox “Development/Apple/Apple Lists - Applescript Users”. (372668800)
the difference between the two of them is that in the inbox case, the error pops up at the line :" set visible messages of viewer to selected messages of viewer". With the mailbox folder right from the start at set msgAccount to name of account of mailbox of msg.
How is this possible, in the first three trials because the selected message is the same.
The return value reads ( also at the test point in code in all the cases),
{message id 446613 of mailbox “INBOX” of account “rvamerongen” of application “Mail”, “rvamerongen”, “INBOX”}
Please, can anyone help me out with this?
BTW, How can I change the title of a newly created message viewer window?
Rene van Amerongen