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

Hi there,

When I run this:

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

I get the following in Result:

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:

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

Hi,

either with a forced error and parsing the error text


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


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

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