FasdUAS 1.101.10 k l Mail attachment save script by Luke Jaeger www.trickfilm.org This script will mine a list of Mail messages for attachments and save them to a destination you choose. The script creates a subfolder for each message with attachments, named with the subject of the message and its date sent. All attachments are saved with their original names. Messages without attachments are ignored. After running, the script will send a mail message detailing what was saved. The script is ready to use as a rule action in Mail - just fill in the specifics of your destination folder and recipient. I wrote this script to deal with large art files sent to me via Mail. Hope you find it useful!  l  l  l  l l comment the first two lines ("using terms" and "on perform") and their accompanying "end" statements when testing. Uncomment them to use this script as a Mail rule function. l w i I .emalcpmanull@mssg o 0 themessages theMessages  pmar o 0theruletheRule k O !" !k ##$% $l%&' &l( (C=here's where you tell Finder to mount your server volume, etc')* )l+ +RLset theOutputFolder to (here's where you tell it the main folder to save in)*,- ,l-./ .r01 0m2 2,&Macintosh HD:Users:james:moblog:cache: 1o 0 outputfolder OutputFolder/3 3l "m44null߀ Finder.appU:IΘHn`6hɘ<Θ0 ɘ\MACSalisr Macintosh HDH+ Finder.appB6n CoreServices6n 3Macintosh HD:System:Library:CoreServices:Finder.app Finder.app Macintosh HD&System/Library/CoreServices/Finder.app/ 56 5l 67 7O 89 8k::;< ;l= =pjcomment the following line when running this script as a Mail.app rule function - uncomment it for testing<>? >l?@A @lB B"set theMessages to selectionACD ClDEF EXGH GkIIJK JlKLM LlN NGAthis is the bit I wrote to create a textfile called "message.txt"MOP OlQ Q"in /Users/james/moblog/cachePRS RlT T?9containing the text of the message. It works. Hooray! SUV Ur$WX Wn"YZ Y1 "  ctnt Zo 0 themessage theMessage Xo 0 thecontentV[\ [Q%S]^ ]k(J__`a `l((b b60 If this is not being executed as a rule action,acd cl((e e60 getting the name of theRule variable will fail.dfg fr(-hi hn(+jk j1)+  pnam ko() 0theruletheRule io 0 therulename theRuleNameglm lr.5no nb.3pq pb.1rs rm./t tThe rule named ' so/0 0 therulename theRuleName qm12u u' matched a message oo 0thetexttheTextmvw vr69xy xo67 0thetexttheText yo 0thetexttheTextwz{ zl::| | display dialog theText{}~ }r:= m:; 71Macintosh HD:Users:james:moblog:cache:message.txt o 0 this_file~ n>F I?F 0 write_to_file o?@ 0 thecontent o@A 0 this_file mAB  boovfals f>? rGJ mGH  o 0thetexttheText ^R .ascrerr ********\ lTT lTT lTT =7does the message have attachments? if not, then skip it ZT >TZ lTW nTW 2UW  attc oTU 0 themessage theMessage JWY k] r]b l]` n]` 2^`  attc o]^ 0 themessage theMessage o 0theattachmentstheAttachments Xc ks rs~ bs| lsx csx ost 0 outputfolder OutputFolder mtw  TEXT lx{ nx{ 1y{  pnam oxy 0 theattachment theAttachment o 0thepaththePath l l >8if same named file already exists in subfolder, skip it  l *$otherwise, save it and get its size  l Z H l I .coredoexboolobj l n 4  alis o 0thepaththePath m4 k I .coresavenullobj o 0 theattachment theAttachment  kfil o 0thepaththePath Z ? n 1  atsz o 0 theattachment theAttachment mB@ r b l c l ^ l I .sysorondlong doub l ^ l n 1  atsz o 0 theattachment theAttachment m( md m  TEXT m  MB o 0mysizemySize r b l~ c l} [ l| I{z {.sysorondlong doub ^ ly n 1x x atsz ow w0 theattachment theAttachmenty mvvz| muu} mt t TEXT~ m   KB os s0mysizemySizer r b b b b   oq q0 thefilelist theFileList  op p ret  l o  n   1n n pnam om m0 theattachment theAttachmento 1l l tab lk oj j0mysizemySizek oi i0 thefilelist theFileListrh lgfgfh 0 theattachment theAttachment ofge e 0theattachmentstheAttachments Idc d.sysoexecTEXTTEXT m #/Users/james/moblog/moblog.shc r  mb b boovtrue n 1 a a isrd o` `0 themessage theMessage l__ ,&display dialog "done the shell script"^ l]\]\^ 0 themessage theMessage Ho[ [0 themessages theMessagesF lZYZY !X !lWVWVX 9m null#Mail.app ʘ)l `6`ʘ!Xʘ(sʘ\nemalalisD Macintosh HDH+Mail.appþM*` ApplicationsM*`"Macintosh HD:Applications:Mail.appMail.app Macintosh HDApplications/Mail.app/"# "lUTUT#$% $lSRSR%&' &lQPQP'() (i*+ *IO,N O0 write_to_file,-. -oM M 0 this_data./0 /oL L0 target_file01K 1oJ J0 append_dataKN +Qc234 2k:5567 6r89 8c:; :l? >r @A @I DBC D.rdwropenshorfile B4 CD C file Do B B0 target_fileCAE@ A perm Em? ? boovtrue@ AlF> Fo= =0open_target_file>?GH GZ'IJ<; I=KL Ko: :0 append_data Lm9 9 boovfals JI#8MN 8.rdwrseofnull**** MlO7 Oo6 60open_target_file7N5P4 5 set2 Pm334<;HQR QI(12ST 2.rdwrwritnull**** So()1 1 0 this_dataT0UV 0 refn Ul*+W/ Wo*+. .0open_target_file/V-X, - wrat Xm,-+ + rdwreof ,RYZ YI27*[) *.rdwrclosnull**** [l23\( \o23' '0open_target_file()Z]& ]L8:^ ^m89% % boovtrue& 3R$#" $.ascrerr ********#" 4kBc__`a `QB`bc! bkEWddef eIEM g .rdwrclosnull**** g4EIh  file hoGH 0 target_filefij i=NQkl koNO 0 this_dialog lmOPm mwhoops - error!jn nIRWo .sysodlogaskrTEXT ooRS 0 this_dialog cR .ascrerr ********!ap pLacq qmab  boovfals)rs rlst tl uvw u .emalcpmanull@mssg 0 write_to_filev  xy .emalcpmanull@mssg 0 themessages theMessages  pmar 0theruletheRulex  0 themessages theMessages 0theruletheRule 0 outputfolder OutputFolder 0 themessage theMessage 0 thecontent 0 therulename theRuleName 0thetexttheText 0 this_file 0theattachmentstheAttachments 0 theattachment theAttachment 0thepaththePath 0mysizemySize 0 thefilelist theFileListy#42tu  kocl  cobj .corecnte********  ctnt  pnam 0 write_to_file  attc  TEXT  alis .coredoexboolobj  kfil .coresavenullobj  atszB@( .sysorondlong doubd  ret  tab .sysoexecTEXTTEXT  isrdEOPUO [l kh,EO',EO%%EOEOEO)fm+ OEWX hO-jv-EO[l kh a&,%EOa/j  fal Oa,a a,a!j a!a&a%EYa,a!j aa&a%EO_%,%_%%EYhOP[OYyYhOa j !Oea",FOP[OY OPUw+z{ 0 write_to_file|| 0 this_data 0 target_file 0 append_dataz 0 this_data 0 target_file 0 append_data 0open_target_file 0 this_dialog{m  ctxt  file  perm .rdwropenshorfile  set2 .rdwrseofnull****  refn  wrat  rdwreof  .rdwrwritnull**** .rdwrclosnull**** .sysodlogaskrTEXTd<&EO*/el EOf jl YhO Oj OeW(X */j OOj WX hOfascr ޭ