First, I am rather new to Applescript, so forgive my ignorance.
I am using Devonthink Office Pro for organizing and capturing my workflow and I have set up two applescripts to import mail into Devonthink: one on command and one as a Rule. I set up a separate mail account so that any message coming into that account will be automatically imported to devonthink inbox and deleted from the Mail App. This way I can use my iphone and other computers to send thought or ideas to my Devonthink inbox. It works great, however it will not import any attachments into the devonthink inbox with the mail message. It simply leaves them behind and they get deleted in the Mail Rule. I contacted Devonthink and they said the script needs to be modified or changed.
Please help! I am copying two scripts below for you to see what is possibly missing and where I could add it to make it work. Let me know what you think.
1) This script is for the Mail Rule to import Mail when it arrives in Mail inbox:
-- Mail Rule Action Import to DEVONthink Pro.
-- Created by Christian Grunenberg on Mon Apr 19 2004.
-- Copyright (c) 2004-2009. All rights reserved.
-- this string is used when the message subject is empty
property pNoSubjectString : "(no subject)"
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with theMessage in theMessages
my importMessage(theMessage)
end repeat
end tell
end perform mail action with messages
end using terms from
on importMessage(theMessage)
tell application "Mail"
try
set theDateReceived to the date received of theMessage
set theDateSent to the date sent of theMessage
set theSender to the sender of theMessage
set theSubject to subject of theMessage
if theSubject is equal to "" then set theSubject to pNoSubjectString
set theSource to the source of theMessage
set theReadFlag to the read status of theMessage
tell application id "com.devon-technologies.thinkpro2"
set theRecord to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string)} in incoming group
set unread of theRecord to (not theReadFlag)
end tell
end try
end tell
end importMessage
2) The other one below is to import on Command from the scripts menu:
-- Import selected Mail messages to DEVONthink Pro.
-- Created by Christian Grunenberg on Mon Apr 19 2004.
-- Copyright (c) 2004-2009. All rights reserved.
-- this string is used when the message subject is empty
property pNoSubjectString : "(no subject)"
tell application "Mail"
try
tell application id "com.devon-technologies.thinkpro2"
if not (exists current database) then error "No database is in use."
end tell
set theSelection to the selection
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)
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)
tell application "Mail"
try
set theDateReceived to the date received of theMessage
set theDateSent to the date sent of theMessage
set theSender to the sender of theMessage
set theSubject to subject of theMessage
if theSubject is equal to "" then set theSubject to pNoSubjectString
set theSource to the source of theMessage
set theReadFlag to the read status of theMessage
tell application id "com.devon-technologies.thinkpro2"
set theRecord to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string)} in incoming group
set unread of theRecord to (not theReadFlag)
end tell
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
If you have any advice, it would be greatly appreciated!
thanks!
phil
Model: MacBook Pro 2.2 Ghz Intel, 2 GB Ram
AppleScript: 2.0.1
Browser: Safari 528.17
Operating System: Mac OS X (10.5)