using terms from application "Mail" on perform mail action with messages theMessages for rule theRule tell application "Finder" --here's where you tell Finder to mount your server volume, etc --set theOutputFolder to (here's where you tell it the main folder to save in) set OutputFolder to "Macintosh HD:Users:james:moblog:cache:" end tell tell application "Mail" --comment the following line when running this script as a Mail.app rule function - uncomment it for testing --set theMessages to selection repeat with theMessage in theMessages --this is the bit I wrote to create a textfile called "message.txt" --in /Users/james/moblog/cache --containing the text of the message. It works. Hooray! set thecontent to content of theMessage try -- If this is not being executed as a rule action, -- getting the name of theRule variable will fail. set theRuleName to name of theRule set theText to "The rule named '" & theRuleName & "' matched a message" set theText to theText -- display dialog theText set this_file to "Macintosh HD:Users:james:moblog:cache:message.txt" my write_to_file(thecontent, this_file, false) set theText to "" end try --does the message have attachments? if not, then skip it if (every mail attachment of theMessage) ­ {} then set theAttachments to (every mail attachment of theMessage) repeat with theAttachment in theAttachments set thePath to (OutputFolder as string) & (name of theAttachment) --if same named file already exists in subfolder, skip it --otherwise, save it and get its size if not (exists (alias thePath of application "Finder")) then save theAttachment in thePath if file size of theAttachment > 1000000 then set mySize to (((round ((file size of theAttachment) / 10240)) / 100) as string) & " MB" else set mySize to (((round (file size of theAttachment) / 1024) + 4) as string) & " KB" end if set theFileList to theFileList & return & (name of theAttachment) & tab & (mySize) end if end repeat end if do shell script "/Users/james/moblog/moblog.sh" set read status of theMessage to true --display dialog "done the shell script" end repeat end tell end perform mail action with messages end using terms from on write_to_file(this_data, target_file, append_data) try set the target_file to the target_file as text set the open_target_file to open for access file target_file with write permission if append_data is false then set eof of the open_target_file to 0 write this_data to the open_target_file starting at eof close access the open_target_file return true on error try close access file target_file this_dialog = "whoops - error!" display dialog this_dialog end try return false end try end write_to_file