Anybody managed to import their unix mailfile into mail

It is scaringly easily to do so manually, as Mail “sniffs” its way to the unix mailbox if you click “ok” to fast. (In the parent folder). But it just seems not listening to the import mail mailbox statement.

This is the code I have used

set mf to POSIX file “/Users/ME” as text
set ma to mf as alias

try
tell application “Mail”
activate
import Mail mailbox at a reference to “/Users/me/mymailbox”
end tell
on error e
display dialog e
end try

– it just doesn1t work

Best Regards

McUsr

The Mail.app dictionary says that the parameter at should be Unicode text and AppleScript works usually with HFS paths.

try this


set mf to path to home folder as text

try
	tell application "Mail"
		activate
		import Mail mailbox at (mf & "mymailbox")
	end tell
on error e
	display dialog e
end try

Hello and thanks.

I didn’t help much though. But I have had some progress: When I had a file named with .mbox the format menu of mail greyed out :D. Having read the dictonary thoroughly (ScriptDebuggers) it said that the import command takes a file object and that the file specifier is of type string - (which is unicode text nowadays?)

I just wanted to add that what I want to achieve with this is a method to import the unix mail into somefolder in Mail.app (together with) a rule action which moves new messages on a regular basis) as The easy solution for getting access to the unix mail. -Any suggestions about working solutions for achieving this for Snow Leopard are very welcome.

Applescripts dictionary says nothing of the type; what dictionary do you use?

– here is the code, which blackens out the format menu if given a mailbox file ending in mbox and does nothing if
no extension is givien.

set mf to path to desktop as text
– set x to a reference to file (mf & “mailfile”)
set x to a reference to file “Macintosh HD:private:var:mail:mymailfile”
try
tell application “Mail”
activate
import Mail mailbox at x
end tell
on error e
display dialog e
end try

SOLVED!

Axel at applescript-users mailing list had the solution:

"
Looks like Mail’s “import Mail mailbox” command is restricted to mailboxes created by Mail, with either a post-Panther or a pre-Tiger format.

Since your mymailfile is a unix mbox, it is easy to create a pre-Tiger Mail mailbox; for example, assuming there’s no name conflict with current contents of directory /tmp:

create directory /tmp/mymailfile.mbox
move (or copy) mymailfile to /tmp/mymailfile.mbox/mbox

It should now be possible to proceed with the import:

tell application "Mail" to import Mail mailbox at POSIX file "/tmp/mymailfile.mbox"

"

I followed his advice and it damn well worked ! :smiley:

Best Regards

McUsr