Mi flujo de trabajo es etiquetar y poner todos los documentos entrantes de Mail.app en Devonthink. Hago esto con Applescript. El script está funcionando bien para mí con una excepción: no sé cómo hacerlo para expandir los archivos .zip y .rar en los archivos adjuntos antes de moverlos a Devonthink. Probablemente requeriría Unarchiver o alguna otra utilidad de archivo de secuencias de comandos. Agradecería sus sugerencias. Mi script está debajo.
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