Re: Extracting attachment from Mail
Re: Extracting attachment from Mail
- Subject: Re: Extracting attachment from Mail
- From: Jeremy Sellors <email@hidden>
- Date: Wed, 5 Mar 2003 11:24:27 -0800
In my case I transfered all the e-mail info into FMPro were I can link
it with the client and then I run a separate external script called
from FMPro that extracts the Files into the clients folder.
The FMPro field that is set by the <set cell "E_mail Body" to theBody
as string> line is not very readable so I have made a calc field that
substitutes the return character.
Substitute(E_mail Body, "Pasted_Return_character", "6") .
The search string is square return character I cut and paste out of the
text of the "E_mail Body" cell. It looks like the del key logo on an
extended keyboard when pasted into FMPro calculation window.
1st script:
tell application "Mail"
if (count of selected messages of message viewer 1) is not 0 then
set allMessages to selected messages of message viewer 1
else
display dialog "Please select some messages to export first" buttons
"Cancel" default button "Cancel"
end if
end tell
tell application "Mail"
set curMessage to ""
set counter to 0
repeat with curMessage in allMessages
set counter to counter + 1
set MessageID to item counter of allMessages
set Messageidcode to message id of MessageID
set MessageMailBox to mailbox of curMessage
set MessageNumber to number of curMessage
set theSender to sender of curMessage
set theSubject to subject of curMessage
set theBody to content of curMessage
set theDate to date sent of curMessage
set MessageCode to source of curMessage
tell application "FileMaker Pro"
activate
tell document "E_Mail Archive.fp5"
set newRecord to create new record
go to newRecord
tell current record
set cell "Recieved E_Mail Date" to theDate as string
--set cell "E_MailDate mins" to ((theDate + minutes) as date)
set cell "E_mail Sender" to theSender as string
set cell "E_mail Body" to theBody as string
set cell "E_mail Subject" to theSubject as string
set cell "Mail.app E_mail name" to Messageidcode as string
set cell "E_mail MIME source" to MessageCode as string
end tell
end tell
end tell
end repeat
end tell
:End Script
I now link each record with the client to get the location of the
clients folder.
Then I call the second script saved as an application and based on John
Delacour's script that extracts the attachments.
Start script:
tell application "FileMaker Pro"
activate
tell document 1
set destinationFold to cell "Client Folder Path" of current record
end tell
end tell
set sourceCode to ""
set tempfile to "/tmp/temp.txt"
set fileMac to POSIX file tempfile
tell application "FileMaker Pro"
tell document 1
set sourceCode to cell "E_mail MIME source" of current record
end tell
end tell
try
close access fileMac
end try
open for access fileMac with write permission
set eof fileMac to 0
write sourceCode to fileMac
close access fileMac
tell application "StuffIt Expander"
Expand {fileMac} Destination destinationFold
quit
end tell
:end script
Now I have to link a preview of the attachment to my FMPro images file
that etc., etc.
\
I have the same problem as Jeremy Sellors. I am unable to save an
attachment from mail.app using applescript. I did not understand John
Delacour's Perl script to parse the attachment.
ThumbsUp
_______________________________________________
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.