Quantcast
Channel: DEVONtechnologies Community - Latest posts
Viewing all articles
Browse latest Browse all 16117

Mail script only working manually

$
0
0

– 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.”

set theGroup to preferred import destination

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 then

set theFile to theFolder & (name of theAttachment)

tell theAttachment to save in theFile

tell application id “DNtp”

set theAttachmentRecord to import theFile to theGroup

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


Viewing all articles
Browse latest Browse all 16117

Trending Articles