Actually I am new in applescript. I just found this one on net and this is the code for this :
(* This script will save message attachments to a folder you have previously selected. The script will expand any files which Stuffit Expander can handle, and will delete the original stuffed file. You can change the folder any time by running the script with the command key held down, if you have Jon’s Commands scripting addition installed. You have the option to delete the attachments from the message (and the OE database) when they are saved to the folder as files, and another option to have the unstuffed file open automatically if you have the application that will open it, or to select it in the attachments folder, or to remain in OE and do nothing except save the unstuffed attachment. You can override your own default choice in any particular message: By holding the Shift key down (with Jon’s installed) you can change the option to “Select”, holding down “Control” will keep you in OE, and holding down both Shift and Control will open the files or folders just for that particular message.
You can run the script from a Mail Rule on every message where . If you choose to use the script in conjunction with “Find Attachments”, a record is made at the top of the message of the attachments(s) that came with it. Then run Find Attachments any time you have one of these messages with an Attachment record displayed, and your saved attachment will either open or be reveales in its folder, whichever you prefer. Again you can override your choice by the same Shift (to Select only) or Shift + Control (to open) on any given occasion.
Put Save/Expand Attachments 2.0 and Find Attachments scripts into your effective Script Menu Items folder:in your Microsoft Users Data folder in your Documents folder, if you have one, or your Outlook Express folder if you don’t. Then just access it from the Script menu within Outlook Express. Install Akua Sweets iand Stuffit Commands scripting additions in the Scripting Additios folder of your System folder and restart your computer (first time only).
Requirements: Outlook Express 4.5 / 5.0, Akua Sweets 1.4, Stuffit Commands 5.5 scripting additions available free at http://macscripter.net
Author: Paul Berkowitz berkowit@humanitas.ucsb.edu *)
property whichFolder : “” – will be alias, not string
property removeAttch : false
property openFile : “no”
property makeReference : false
property findAttachments : “” – will be an alias, not a path
property delOriginals : true
property unStuff : “Yes”
try
set inputState to «event AkuiKbdX» – Akua Sweets
if {«class îMod»:“C”} is in inputState then
set whichFolder to “”
set removeAttch to false
set openFile to “no”
set makeReference to false
set delOriginals to true
set unStuff to “Yes”
else if {«class îMod»:“S”} is in inputState then
set remember to openFile
set openFile to “selectOnce”
else if {«class îMod»:“^”} is in inputState then
set remember to openFile
set openFile to “notThisTime”
else if {«class îMod»:“^S”} is in inputState then
set remember to openFile
set openFile to “openOnce”
end if
end try
if whichFolder = “” then
set whichFolder to (choose folder with prompt “Choose a folder for your attachments.”)
display dialog "Do you want to remove all attachments from the message when they are saved to their folder?" & return & return & "You can reset this preference, and your choice of folder, by holding down the command key when you run the script with Akua Sweets osax installed." buttons {"Don't Remove", "Remove"} with icon 1
if button returned of result = "Remove" then set removeAttch to true
display dialog "Do you want stuffed files to be automatically unstuffed?" & return & return & "(**Opening files automatically from this script is only available if you choose to unstuff, but may be done later from Find Attachments script with either choice here.)" buttons {"No", "Yes"} default button "Yes" with icon note
set unStuff to button returned of result
if unStuff = "Yes" then
display dialog "Should the original stuffed files be deleted when unstuffing is successful?" buttons {"No", "Yes"} default button "Yes" with icon note
if button returned of result = "No" then
set delOriginals to false
else
set delOriginals to true -- may need to be reset
end if
display dialog "Do you want the unstuffed files or folders to open when this script is run, or do you want to be taken to the selected files in your saved attachments folder, or neither (NO ACTION)?" & return & return & "! Choose NO ACTION if you will be running this script from a Mail Rule." buttons {"Open File", "Take Me There", "No Action"} default button "No Action" with icon 1
if button returned of result = "Open File" then
set openFile to "open"
else if button returned of result = "Take Me There" then
set openFile to "select"
end if
else
display dialog "Do you want be taken directly to the selected files in your saved attachments folder when this script is run, or not?" & return & return & "Choose No Action if you are running this script from a Mail Rule." buttons {"Cancel", "Take Me There", "No Action"} default button "No Action" with icon 1
if button returned of result = "Cancel" then
return
else if button returned of result = "Take Me There" then
set openFile to "select"
end if
end if
display dialog "Do you want to use Find Attachments 2.0 script to find the saved expanded files at any time?" & return & return & "If so, this script will record the details of the attachment name(s) and alert you by coloring the message (subject) russet in the message pane." buttons {"No", "Yes"} default button "Yes" with icon note
if button returned of result = "Yes" then
set makeReference to true
set findAttachments to choose file of type {"osas"} with prompt "Where is Find Attachments 2.0 script?"
end if
return
end if
tell application “Outlook Express”
set theMsg to item 1 of (get current messages)
set theAttachments to the attachments of theMsg
try
set theContent to content of theMsg as Unicode text – OS 8.5+
on error
set theContent to content of theMsg – earlier OS
end try
end tell
set refText to “”
set selectFiles to {}
repeat with i from (length of theAttachments) to 1 by -1
set theAttachment to item i of theAttachments
set theName to name of theAttachment
set AppleScript's text item delimiters to {":"}
set ls to text items of theName
set AppleScript's text item delimiters to {"-"}
set theName to ls as string
set AppleScript's text item delimiters to {""}
if length of theName > 31 then
set theName to text 1 thru 30 of theName & "…"
end if
set j to 1
try
get alias ((whichFolder as string) & theName) -- if successful means file or folder already exists
if length of theName > 28 then
set theName to text 1 thru 27 of theName & "…"
end if
set theName to theName & ".1"
repeat
try
get alias ((whichFolder as string) & theName) -- if successful means file or folder already exists
set j to j + 1
set theName to text 1 thru -2 of theName & j
on error
exit repeat
end try
end repeat
end try -- leave it be if file or folder doesn't exist
set FilePath to ((whichFolder as string) & theName)
try
save theAttachment in FilePath
on error errMsg number errNum
display dialog " There was an error trying to save the attachment "" & theName & ""." & return & return & "You will need to handle this message manually." & return & return & errNum with icon stop
return
end try
set theFile to FilePath as alias
set err to false
if unStuff = "Yes" then
if («event SITcDtFt» (theFile as file specification)) != "Unknown" then
try
«event SITcXpnd» theFile given «class dele»:delOriginals -- Stuffit Commands osax, true if delOriginals true, false if false
on error number errNum
if errNum != -2 then
tell application "Outlook Express" to activate
if {openFile} is in {"open", "openOnce", "select", "selectOnce"} then
display dialog "Sorry – Stuffit Expander could not unstuff this file: " & return & return & theName & return & return & "It will be displayed and selected in your saved attachments folder." with icon 2
else
display dialog "Sorry – Stuffit Expander could not unstuff this file: " & return & return & theName & return & return & "It can be found in your saved attachments folder." with icon 2
end if
set err to true
set expFile to theFile
if makeReference is true then
set refText to (refText & return & "Attachment: " & theName & " (stuffed)")
set newRecord to {msgID:id of theMsg, savedFile:theFile, name:theName, stuffed:true}
set foundScript to load script findAttachments
set end of foundScript's refRecords to newRecord
store script foundScript in findAttachments with replacing
end if
end if
end try
if err is false then -- not when errored unstuffing
set expFile to result as alias
end if
else -- means file wasn't stuffed, DTF = "Unknown"
set expFile to theFile
end if
else -- no unstuffing
set expFile to theFile
set err to true -- so "stuffed" property of newRecord will be set to "true" below
end if
set expPath to expFile as string
set AppleScript's text item delimiters to {":"}
if character -1 of expPath != ":" then
set expName to text item -1 of expPath
else
set expName to text item -2 of expPath
end if
set AppleScript's text item delimiters to {""}
if makeReference is true then
set refText to (refText & return & "** Saved Attachment: " & expName)
set newRecord to {msgID:id of theMsg, savedFile:expFile, name:expName, stuffed:false}
if err is true then set stuffed of newRecord to true -- still stuffed
set foundScript to load script findAttachments
set end of foundScript's refRecords to newRecord
store script foundScript in findAttachments with replacing
end if
if err is false then
if {openFile} is in {"open", "openOnce"} then
tell application "Finder"
if class of expFile is file then
set creaType to creator type of expFile
try
set theAppFile to application file id creaType as alias
try
tell application (theAppFile as string) to open expFile
on error
set AppleScript's text item delimiters to {":"}
set appFileName to last text item of (theAppFile as string)
set AppleScript's text item delimiters to {""}
display dialog " For some reason, the application " & appFileName & " cannot open the unstuffed file "" & expName & ""." & return & return & "You had better try manually when the script is finished: the file will be selected in your saved attachments folder." with icon 2
set err to true -- now select
end try
on error
display dialog "You don't appear to have the application needed to open the file "" & expName & "": its creator type is " & return & return & " "" & creaType & """ & return & return & "You had better try manually when the script is finished: the file will be selected in your saved attachments folder." with icon 2
set err to true
end try
else -- if folder
activate
open expFile
end if
end tell
else if {openFile} is in {"select", "selectOnce"} then -- still where err is false
set end of selectFiles to expFile
end if
end if
if ({openFile} is in {"open", "openOnce", "select", "selectOnce"}) and err is true then -- err true = problem unstuffing, or "don't unstuff" option taken
set end of selectFiles to expFile -- though not actually expanded
end if
if removeAttch is true then tell application "Outlook Express" to delete theAttachment
end repeat
if makeReference is true then
try
set refText to (refText & return & return) as Unicode text – OS 8.5+
set newContent to «event AkuuDtaA» refText given «class at »:-1, «class usin»:theContent
on error
set theContent to theContent as string – in case OS 8.5 but no Akua
set refText to (refText & return & return)
set newContent to refText & theContent
end try
tell application "Outlook Express"
set content of theMsg to newContent
if removeAttch is true and theAttachments != {} then set color of theMsg to {57311, 17990, 4883} -- don't color if run from another rule without attachment criterion
end tell
else
if removeAttch is true and theAttachments != {} then
tell application “Outlook Express” to set color of theMsg to {57311, 17990, 4883} – don’t color if run from another rule without attachment criterion
end if
end if
if {openFile} is in {“select”, “selectOnce”} and selectFiles != {} then
tell application "Finder"
select every item of selectFiles -- gets them evaluated as Finder files instead of alias
set theFinderFiles to the result as list -- in case only 1
activate
open container of (last item of theFinderFiles)
select theFinderFiles
end tell
end if
if {openFile} is in {“openOnce”, “selectOnce”, “notThisTime”} then set openFile to remember