Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Open a Mail Message via ID with just AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open a Mail Message via ID with just AppleScript
Authored by: unclecal on Mar 18, '07 02:55:20PM

You can open a message directly via applescript without the need for MailTags via the function below. But, make sure the TargetID isn't encased in <>.

on run {TargetAccount, TargetMailbox, TargetID}
    tell application "Mail"

        set myMailbox to mailbox TargetMailbox of account TargetAccount
        set myMessages to (messages of myMailbox)

        repeat with eachMessage in myMessages
           if message id of eachMessage is TargetID then
               tell eachMessage
                  exit repeat
               end tell
           end if
       end repeat

    end tell
end run

I'm guessing the script could be refined further to directly reference the desired message by ID without a loop. But the loop works well.

[ Reply to This | # ]