Re: export e-mail attachments
Re: export e-mail attachments
- Subject: Re: export e-mail attachments
- From: John Delacour <email@hidden>
- Date: Sun, 2 Mar 2003 19:07:55 +0000
- Mac-eudora-version: 6.0a8
At 12:33 pm -0800 1/3/03, Jeremy Sellors wrote:
How can I save e-mail attachments in Mail.app?
I need to import selected e-mails into FileMaker Pro and save the
attachment to a folder.
I see you've had no reply from the person who believes Mail to be
scriptable, so while we wait for a one-liner from that quarter,
here's a contorted script almost worthy of Apple that can do what you
want.
Select a message having an attachment in the message viewer and run
this script. The attachment will be expanded by Stuffit Expander on
to your desktop. If you want to get the text of the message too,
then it will need to be parsed and I haven't bothered with that bit,
excet that after "EXTRA STUFF" I get the whole content of the
message, which will not display if it's too big. There is also the
problem that Mail at some indeterminate point changes the name of the
files, so we have to try to read the final name and if that fails
read the initial name. You'll need to delete the numbered mailboxes
by hand, unless someone tells us otherwise, because Mail turns
phantoms into reality -- and vice versa of course :-)
All great fun!
set d to "1/1/1"
set d to "" & (current date) - (get date d)
tell application "Mail"
set _dir to get the first account's account directory
set my text item delimiters to "/"
set _mailDir to "" & text items 1 through -2 of _dir
set my text item delimiters to ""
set _package to "" & _mailDir & "/mailboxes/" & d & ".mbox/"
set _mailbox to _package & "Incoming_Mail"
make mailbox with properties {name:d}
set _message to item 1 of (get selection)
set _origin to mailbox of _message
set mailbox of _message to mailbox d
end tell
tell application "StuffIt Expander"
Expand {POSIX file _mailbox} Destination (path to desktop)
end tell
tell application "Mail"
set _message to message 1 of mailbox d
set mailbox of _message to _origin
end tell
-- EXTRA STUFF
set s to do shell script "perl -e '
open F, qq~" & _package & "mbox~; for (<F>) {print} '"
if s = "" then
set s to do shell script "perl -e '
open F, qq~" & _package & "Incoming_Mail~; for (<F>) {print} '"
end if
--do shell script "rm -r " & _package
return s
--JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.