applescript - Exporting messages selected in Mail.app as emlx -
i want export selected emails given mailbox finder. found script on internet , altered likes. doen't seems export. know going wrong?
tell application "mail" set msgs message of mailbox "test1" of account "info" if length of msgs not 0 display dialog "export selected message(s)?" if button returned of result "ok" -- set month parsing value french vanilla algorithm set fixeddate current date --or other date set month of fixeddate january -- set thefolder "macintosh hd:users:rajsingh:desktop:" alias set thefolder choose folder prompt "save exported messages to..." without invisibles repeat msg in msgs -- path message set mb mailbox of msg set mba account of mb -- mtype returning 'constant **** etim' when should imap (for ogc account) -- set mtype (account type) of mba set mtype "imap" set accountpath account directory of account of mb set fullpath accountpath & name of mb & "." & mtype & "mbox:messages:" -- figure out message name set msgfilename id of msg set atts number of mail attachments of msg if atts > 0 set msgfilename msgfilename & ".partial.emlx" else set msgfilename msgfilename & ".emlx" end if set fullpath fullpath & msgfilename set thefile fullpath rich text -- create new name prefix based on date set msgdate date received of msg -- parse date -- use french vanilla algorithm month number set themonth (2 + (msgdate - fixeddate + 1314864) div 2629728) rich text if length of themonth < 2 set themonth "0" & themonth end if set theday day of msgdate rich text if length of theday < 2 set theday "0" & theday end if set msgdate (year of msgdate rich text) & themonth & theday & "at" & hours of msgdate & minutes of msgdate & seconds of msgdate set comparison_string ":/" set replacement_string "->" set msgsubject "" set msgsubject replacetext("re- ", "", msgsubject) set msgsubject replacetext("re-", "", msgsubject) --set msgsubject text 1 thru 49 of msgsubject set newfile msgsubject & "_" & msgdate & ".emlx" rich text --set newfile (msgsubject & "_" & msgdate & "_" & msgfilename) text -- copy mail message folder , prepend date-time file name tell application "finder" try set intfile "" duplicate file thefile folder thefolder on error display dialog thefile & thefolder display dialog "couldn't duplicate " & intfile end try -- rename file try set name of intfile newfile on error display dialog "couldn't set name of " & intfile & " " & newfile end try -- reveal intfile -- open thefile alias end tell end repeat beep 2 display dialog "done exporting " & length of msgs & " messages." end if -- ok export msgs end if -- msgs > 0 end tell on replacetext(find, replace, subject) set prevtids text item delimiters of applescript set text item delimiters of applescript find set subject text items of subject set text item delimiters of applescript replace set subject "" & subject set text item delimiters of applescript prevtids return subject end replacetext
your following script works fine, want include in rules i'm total newbie scripting.
thanks answer
__________________________________
tell application "mail"
selected messages of message viewer 1
repeat m in result
shell script "find ~/library/mail/v2 -name " & (get id of m) & ".\* -exec cp {} ~/desktop/" & quoted form of replace(subject of m, "/", "") & ".emlx \;"
end repeat
end tell
on replace(input, x, y)
set text item delimiters x
set t text items of input
set text item delimiters y
t text
end replace
________________________________
Comments
Post a Comment