Re: Want to get the full path of the mailbox
Re: Want to get the full path of the mailbox
- Subject: Re: Want to get the full path of the mailbox
- From: Andreas Amann <email@hidden>
- Date: Sun, 17 Dec 2006 19:11:33 -0800
The name only gives me the last component is there a way to get the
full path of the mailbox with Mail.app?
The following works for me to get the location of the actual messages
(mbox in 10.3.x and *.emlx in 10.4.x) for a mailbox "theBox" - for
all types of accounts and mailboxes as well as any system starting
with 10.3:
--
on getMailboxLocation(theBox)
-- locate the folder on disk which contains the actual messages for
the mailbox theBox
set bTiger to ((get system attribute "sysv") ≥ 4160) -- 4160 =
0x1040 is Sytem version 10.4.0 (Tiger)
tell application "Mail"
set theBoxName to my getMailboxPath(theBox)
set theAccount to account of theBox
end tell
set theMboxExtension to ".mbox"
try
set tmpVar to theAccount
set bAccountBox to true
on error
set bAccountBox to false
end try
if bAccountBox then
tell application "Mail" to set thePath to account directory of
theAccount
set AppleScript's text item delimiters to name of theAccount
set theBoxName to text items 2 thru -1 of theBoxName as text
tell application "Mail"
if account type of theAccount is in {imap, Mac} then
if bTiger then
set theMboxExtension to ".imapmbox/Messages"
else
set theMboxExtension to ".imapmbox/CachedMessages"
end if
else
if bTiger then
set theMboxExtension to ".mbox/Messages"
end if
end if
end tell
else
if bTiger then
set theMboxExtension to ".mbox/Messages"
end if
set thePath to (POSIX path of (path to library folder from user
domain as string)) & "Mail/Mailboxes/"
end if
return (quoted form of (thePath & theBoxName & theMboxExtension))
end getMailboxLocation
on getMailboxPath(theBox)
-- extract the full mailbox path for a given mailbox
-- mailboxes for an account will start with the account name
tell application "Mail"
try
set theName to name of theBox
on error -- if this fails, Mail won't let us access the mailbox at
all. An example would be a mailbox whose name ends in ".mbox"
return ""
end try
repeat
try
set theBox to container of theBox
set theName to theBox's name & "/" & theName
on error
exit repeat
end try
end repeat
return theName
end tell
end getMailboxPath
--
Andreas _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden