• 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: Mail Scripting - Copy Messages to Finder Folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail Scripting - Copy Messages to Finder Folder


  • Subject: Re: Mail Scripting - Copy Messages to Finder Folder
  • From: Axel Luttgens <email@hidden>
  • Date: Fri, 28 Jun 2013 12:54:18 +0200

Le 27 juin 2013 à 04:19, Bruce Robertson a écrit :

> [...]
>
> It fails for items in On My Mac mailboxes but works OK for high level mailboxes.
>
> [...]

Hello again,

The problem is, On My Mac mailboxes do not have an account.

So, assuming you really need to take an exact copy of the message as stored by Mail, you'll have to depend on the (undocumented nor guaranteed) internals of Mail and to resort to some kludges depending on strong yet fragile assumptions.

For example, with those two helper handlers (tested here on 10.8.4):

	on MBoxRelativePosixPath(mBox)
		tell application "Mail"
			if name of container of mBox is missing value then return (name of mBox) & ".mbox"
			return my MBoxRelativePosixPath(container of mBox) & "/" & (name of mBox) & ".mbox"
		end tell
	end MBoxRelativePosixPath

	on MBoxPosixPath(mBox)
		try
			tell application "Mail" to get POSIX path of ((account directory of account of mBox) as alias)
		on error
			-- Should be OK starting with 10.7.x (or 10.6.x?)
			get (POSIX path of (path to home folder)) & "Library/Mail/V2/Mailboxes/"
		end try
		return result & MBoxRelativePosixPath(mBox)
	end MBoxPosixPath

it should be possible to circumvent the error you encountered by replacing:

	set myFolder to POSIX path of (account directory of account of mailbox of msg as Unicode text)

with:

	set myFolder to my MBoxPosixPath(mailbox of msg)

This should even be more accurate than the existing script, since an account directory is liable to contain several mailboxes (and sub-mailboxes in the case of an IMAP account), and I'm not sure a message id is guaranteed to be unique across mailboxes.

I haven't verified the find command but, since you are considering 10.7.5, I guess the search on ".eml" files isn't needed: looking for ".emlx" files only should be sufficient.

HTH,
Axel


 _______________________________________________
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/archives/applescript-users

This email sent to email@hidden


References: 
 >Mail Scripting - Copy Messages to Finder Folder (From: Bruce Robertson <email@hidden>)

  • Prev by Date: Re: Mail Scripting - Copy Messages to Finder Folder
  • Next by Date: Re: Changes in 10.8
  • Previous by thread: Re: Mail Scripting - Copy Messages to Finder Folder
  • Next by thread: menu bar 1 in 10.8?
  • Index(es):
    • Date
    • Thread