applescriptapplescript-objcapple-mail

AppleScript - How to Access Mail Directory?


I am trying to access folder in my mail using apple script. but did not succeed.

My folder Name is : BLABLABLA , it resides under Apple Mail .

I think that it should be :

set myDir to mailbox "BLABLABLA"

this does not work, any suggestions ?


Solution

  • This will retrieve the account mailbox

    tell application "Mail"
        set AccountNames to name of accounts
        choose from list AccountNames with prompt "Select the email account" ¬
        without multiple selections allowed
        set AccountName to result as string
        set MailboxesListV to mailboxes of account AccountName
    end tell
    

    Which is what I think you want. (Notice that the result is a list.)

    I hope it helps.