0
votes

I am trying to get a message by its id from Mail.app using Apple Script. It works if the message is still in the inbox, however I have messages on my local mac with the account name "On my mac" whenever I run this script it gives me an error "Mail got an error: Can’t get account "On My Mac". Number: -1728".

# THIS WORKS
# set MessageID to 375586
# set _mailBox to "INBOX"
# set _account to "TheWilliamson"

# THIS DOESN'T WORK
set MessageID to 11351
set _mailBox to "2001"
set _account to "On My Mac"


tell application "Mail"

    try
        set mybox to mailbox _mailBox of account _account

        # ERROR: Mail got an error: Can’t get account "On My Mac". Number: -1728

    on error eStr number eNum
        display dialog eStr & " Number: " & eNum buttons {"OK"} default button 1
        return
    end try
end tell
1

1 Answers

0
votes

The sub "folders" of the "on my Mac" are not accounts, but they are mailbox. Therefore you can get the mailbox using

Set MyMailbox to mailbox of MyMessage --> string with name of the mailbox

Also don't confuse a message and a message ID. the message ID is just a property of your message. fyi, and to make it simple, accounts are the different address emails you have.