Get POSIX path of a mail message in Mail 2 (Mac OS X Lion)

Hi,

Obviously, Apple changed the way emails are sorted in Mail mailboxes in the depths of the user’s library folder in Lion.

Getting the path to the mailbox itself and the email name using AppleScript is an easy task; what I’m missing is a way do get the part between the two.

In Snow Leopard, it was very predictable, as follows:

Now this is how it looks like in Lion:

An experienced user will understand that the last half part of the path is not constant. That IS my problem, since I need the full POSIX path to an email.

I can’t find any information across the Internet relating to this issue. I hope someone here could help me out with a clever solution.

Cheers,

Yannick Gauthier

Model: iMac 27"
Browser: Safari 534.53.10
Operating System: Mac OS X (10.7)

Are you saying that there are multiple subtrees below ‘INBOX.mbox’??

When you can get the email’s filename you can find it with mdfind, which is part of Spotlight’s back end:

set thePath to "/Users/me/Library/Mail/"

do shell script "mdfind -onlyin " & quoted form of thePath & " 'kMDItemFSName = \"9945.emlx\"'"

In 10.6, a mail message has a property ‘id’, which contains the number that is the filename. Not the same as the email’s subject…

HTH

Yes, I was talking about the subtrees, which are not constant like in Snow Leopard.

Thank you for the tip, works as intended!

YG