using this script
-- Mail Rule - Add attachments to DEVONthink
-- Created by Christian Grunenberg on Fri May 18 2012.
-- Copyright (c) 2012-2020. All rights reserved.
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
set theFolder to (POSIX path of (path to temporary items))
repeat with theMessage in theMessages
set theSender to the sender of theMessage
set theID to "<" & message id of theMessage & ">"
set c to 0
repeat with theAttachment in mail attachments of theMessage
try
if name of theAttachment ends with ".pdf" then
-- if downloaded of theAttachment then
set theFile to theFolder & (name of theAttachment)
tell theAttachment to save in theFile
tell application id "DNtp"
set theAttachmentRecord to import theFile to incoming group
set itemPath to path of theAttachmentRecord
set theRecord to ocr file itemPath to incoming group with waiting for reply
delete record theAttachmentRecord
set URL of theRecord to "message://" & theID
-- perform smart rule trigger import event record theRecord
perform smart rule name "a smart rule" record theRecord
set c to c + 1
end tell
-- end if
end if
end try
end repeat
if c > 1 then
set theNotif to "Sent " & c & " PDF attachments to DEVONthink"
display notification theNotif with title "Apple Mail"
set read status of theMessage to true
delete theMessage
else if c = 1 then
set theNotif to "Sent 1 PDF attachment to DEVONthink"
display notification theNotif with title "Apple Mail"
set read status of theMessage to true
delete theMessage
end if
end repeat
end tell
end perform mail action with messages
end using terms from
if I uncomment the line perform smart rule trigger import event record theRecord
and instead comment out the line with the specific smart rule (directly below), then the smart rule (see below) does not trigger. When I use the line which specifically names the smart rule, it does trigger. Any idea why?
DT 3.7 on macOS 11.3.