Tuesday, July 14, 2020

#1 2009-09-07 10:55:52 am

Raimondi
Member
Registered: 2008-11-24
Posts: 2

How to get a Mail.app's mailbox full name

Hi there,

When I run this:

Applescript:

tell application "Mail"
get some mailbox of first account
end tell

I get the following in Result:

Applescript:

mailbox "INBOX/lists/Scid" of account "Gmail" of application "Mail"

the name of the mailbox is shown as a file path ("INBOX/lists/Scid"), but when I get the name of it:

Applescript:

tell application "Mail"
get name of some mailbox of first account
end tell

I get only the last part ("Scid"), is there a way to get the "full" name?

Thanks!
Israel

Last edited by Raimondi (2009-09-07 11:10:52 am)


Filed under: mail

Offline

 

#2 2009-09-07 11:13:49 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11688
Website

Re: How to get a Mail.app's mailbox full name

Hi,

either with a forced error and parsing the error text

Applescript:


try
   tell application "Mail"
       some mailbox as text
   end tell
on error e
   set {TID, text item delimiters} to {text item delimiters, quote}
   set mailboxName to text item 2 of e
   set text item delimiters to TID
end try
mailboxName

or collect the path recursively

Applescript:


tell application "Mail"
   set theBox to some mailbox
   set thePath to name of theBox
   repeat
       try
           set theBox to container of theBox
           set thePath to name of theBox & "/" & thePath
       on error
           exit repeat
       end try
   end repeat
end tell
thePath


regards

Stefan


Filed under: mail

Offline

 

#3 2009-09-07 11:25:56 pm

Raimondi
Member
Registered: 2008-11-24
Posts: 2

Re: How to get a Mail.app's mailbox full name

Nice! as I couldn't find a way to get it in one line, I was wondering how to do the recursive loop, your solution is perfect.

Thanks!
Israel

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)