Sure.
-- Import attachments of selected messages to DEVONthink.
-- Created by Christian Grunenberg on Fri May 18 2012.
-- Copyright (c) 2012-2020. All rights reserved.
tell application "Mail"
try
tell application id "DNtp"
if not (exists current database) 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
set theSender to the sender of theMessage
repeat with theAttachment in mail attachments of theMessage
-- try
if downloaded of theAttachment and (name of theAttachment ends with ".pdf") then
set theFile to theFolder & (name of theAttachment)
tell theAttachment to save in theFile
tell application id "DNtp"
set theAttachmentRecord to import theFile
set URL of theAttachmentRecord to theSender
perform smart rule trigger import event record theAttachmentRecord
end tell
end if
-- end try
end repeat
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