• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get .emlx file for Mail message?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get .emlx file for Mail message?


  • Subject: Re: Get .emlx file for Mail message?
  • From: Philip Aker <email@hidden>
  • Date: Sun, 24 Sep 2006 02:01:13 -0700

On 2006-09-23, at 16:07:14, Luther Fuller wrote:

The line ...

set bpath to name of container of mailbox of sel & ":" & name of mailbox of sel & ".mbox"

has me worried. What if 'sel' is a message inside a mailbox, inside a mailbox, inside a mailbox, inside a mailbox, &c.?

Indeed, 

I had to go out this morning and only had time to sketch. But I see that kai has filled in the details very nicely. Here's a variant on kai's contribution which returns a list of URLs if there are multiple messages selected. It's somewhat optimized (less than 1 second for 10 selected messages) but could probably be tweaked for speed a little more:

script murl
property p : "file://" as Unicode text
property lpath : POSIX path of (path to library folder from user domain)
property prefix : "file://" as Unicode text
on run
set res to {}
tell application "Mail"
set sels to (get selection)
repeat with i from 1 to count of sels
set m to mailbox of item i of sels
set mid to id of item i of sels
tell m
set n to name
if (its account exists) then
tell its account
if (account type is not pop) then set p to ".imapmbox/Messages/"
set end of res to prefix & account directory & "/" & n & p & mid & ".emlx"
end tell
else
set c to its container
repeat while c exists
set p to c's name & "/" & p
set c to c's container
end repeat
set end of res to prefix & lpath & "Mail/Mailboxes/" & p & mid & ".emlx"
end if
end tell
end repeat
end tell
res
end run
end script
run script murl



tell application "Mail"
set mailboxPath to (name of mbox)
--
set mboxCont to mbox
repeat
try
set mboxCont to (container of mboxCont)
set mailboxPath to (name of mboxCont) & "/" & mailboxPath
on error
exit repeat
end try
end repeat
end tell

(You may want to use ":" instead of "/".)

On Sep 23, 2006, at 4:38 PM, Philip Aker wrote:

On 2006-09-23, at 07:27:47, Michael Grant wrote:

Is there any way, in AppleScript or otherwise, to quickly identify the .emlx file corresponding to a given message in Mail?

What I'm trying to do is create text "bookmarks" to specific messages in the form of file:// URIs, which I would then be able to place in any app that processes text. I'm open to another approach, if anyone has any ideas, but the point is to be able to place pointers to a specific message anywhere I want them.

If you're thinking of using "mdfind" route remember to use the "-onlyin" option. But if you want to work out the details of accounts and mailboxes fully, the following takes less than 1 second OMM:

tell application "Mail"
set sel to item 1 of (get selection)
set e_id to id of sel
set bpath to name of container of mailbox of sel & ":" & name of mailbox of sel & ".mbox"
set epath to "file://" & POSIX path of (((path to library folder from user domain) as string) & "Mail:Mailboxes:" & bpath & ":Messages:" & e_id & ".emlx")
end tell


Philip Aker
email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Get .emlx file for Mail message?
      • From: Philip Aker <email@hidden>
References: 
 >Get .emlx file for Mail message? (From: "Michael Grant" <email@hidden>)
 >Re: Get .emlx file for Mail message? (From: Philip Aker <email@hidden>)
 >Re: Get .emlx file for Mail message? (From: Luther Fuller <email@hidden>)

  • Prev by Date: Rép: AppleScript runs slow on Intel Mac's
  • Next by Date: Re: AppleScript runs slow on Intel Mac's
  • Previous by thread: Re: Get .emlx file for Mail message?
  • Next by thread: Re: Get .emlx file for Mail message?
  • Index(es):
    • Date
    • Thread