Il mio flusso di lavoro consiste nel taggare e mettere tutti i documenti in arrivo da Mail.app a Devonthink. Lo faccio con Applescript. Lo script funziona perfettamente con una eccezione: non so come farlo espandere i file .zip e .rar negli allegati prima di spostarli in Devonthink. Probabilmente richiederebbe Unarchiver o qualche altra utility di archiviazione con script. Apprezzerei i tuoi suggerimenti. Il mio script è di sotto.
property pNoSubjectString : "(no subject)"
tell application "Mail"
try
tell application id "com.devon-technologies.thinkpro2"
if not (exists «class DTcu») then error "No database is in use."
end tell
set theSelection to the selection
set theFolder to (POSIX path of (path to temporary items))
if the length of theSelection is less than 1 then error "One or more messages must be selected."
repeat with theMessage in theSelection
my importMessage(theMessage, theFolder)
end repeat
on error error_message number error_number
if error_number is not -128 then display alert "Mail" message error_message as warning
end try
end tell
on importMessage(theMessage, theFolder)
tell application "Mail"
try
tell theMessage
set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag} to {the date received, the date sent, the sender, subject, the source, the read status}
tell application "MailTagsHelper"
tell theMessage
set theTags to the keywords
end tell
end tell
end tell
if theSubject is equal to "" then set theSubject to pNoSubjectString
set theAttachmentCount to count of mail attachments of theMessage
tell application id "com.devon-technologies.thinkpro2"
set theGroup to «class DTig»
if theAttachmentCount is greater than 0 then set theGroup to «event DTpacd08» {name:theSubject, «class DTty»:«constant DtypDTgr»} given «class DTin»:theGroup
set theRecord to «event DTpacd08» {name:theSubject & ".eml", «class DTty»:«constant Dtyp****», «class DTcr»:theDateSent, «class DTmo»:theDateReceived, URL:theSender, «class conT»:(theSource as string), «class tags»:theTags} given «class DTin»:theGroup
set «class DTur» of theRecord to (not theReadFlag)
end tell
repeat with theAttachment in mail attachments of theMessage
set theFile to theFolder & (name of theAttachment)
tell theAttachment to save in theFile
tell application id "com.devon-technologies.thinkpro2"
set theAttachmentRecord to «event DTpacd01» theFile given «class DTto»:theGroup
set «class DTur» of theAttachmentRecord to (not theReadFlag)
set URL of theAttachmentRecord to theSender
set «class tags» of theAttachmentRecord to theTags
end tell
end repeat
on error error_message number error_number
if error_number is not -128 then display alert "Mail" message error_message as warning
end try
end tell
end importMessage