select a smart folder in mail.app

I can select mailboxes in mail.app but I can’t select a smart folder.

Here’s what I can do. I can get the name of a selected mailbox box by selecting something in the left column of mail and running the following script…

tell application "Mail"
	set firstMessageViewer to first message viewer
	set theSelection to selected mailboxes of firstMessageViewer
end tell

Using the mailbox name from the above I can make that selection whenever I want. For example to select the inbox…

tell application "Mail"
	set firstMessageViewer to first message viewer
	set selected mailboxes of firstMessageViewer to {inbox}
end tell

So using that technique I can select many things in mail like the inbox, or the trash, junk mail etc. I can select those things for specific accounts only too. But there are several things I can’t select. A smart folder is one of them. When I try to get the name of a selected smart mailbox using the first script it doesn’t give me a mailbox name - and therefore I don’t know how to select it. Any ideas?

I also can’t select RSS feeds, the main ToDo item, or the main Notes item. Any ideas about those would be helpful too.

Hi,

Unlike iTunes’ smart playlists, smart mailboxes are just (Spotlight) search results like the smart folders in Finder.
You can’t access them with AppleScript (maybe with GUI scripting)

Thanks, that makes sense. I guess I have to live with that.

Any ideas about these things? For example ToDo items. I have several accounts in mail. I can select a ToDo mailbox for a specific email account, but I can’t select the main ToDo item which shows the Todo’s for all accounts… same with Notes. That surprises me. Also RSS feeds have a name and account but they can’t be selected either. Mail is driving me crazy!

I really don’t know. At least there are no commands and properties in Mail’s dictionary.
I guess, Apple has made all these enhancements but has forgotten to enhance also the scriptability

And it’s not as if it were impossible – several other apps will identify and select their smart folders. :frowning: