내 워크 플로는 Mail.app에서 들어오는 모든 문서에 태그를 지정하고 Devonthink에 넣는 것입니다. 나는 Applescript로 이것을한다. 한 가지 예외를 제외하고는 스크립트가 제대로 작동합니다. 첨부 파일에서 .zip 및 .rar 파일을 Devonthink로 이동하기 전에 확장하는 방법을 모르겠습니다. 아마도 Unarchiver 또는 다른 스크립트 가능한 아카이브 유틸리티가 필요할 것입니다. 당신의 제안에 감사드립니다. 내 스크립트는 다음과 같습니다.
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