I’d like to add a step to the end of the “Mail Rule Action Import.app” script that would convert the imported .eml file to rich text. Is this possible? The eml documents created aren’t viewable in the web server interface, so rich text is much better for my usage.
This doesn’t work, but I thought somebody might be able to tell me why:
-- 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
tell theMessage
set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag} to {the date received, the date sent, the sender, subject, the source, the read status}
end tell
if theSubject is equal to "" then set theSubject to pNoSubjectString
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)
convert record theRecord to rich text
end tell
end try
end tell
end importMessage
The only thing I’ve changed from the script that shipped was adding the “convert record…” line. Any thoughts or suggestions?
A couple of issues:
- According to the applescript library, the constant should be ‘rich’ rather than ‘rich text’
- Convert creates a transformed duplicate, and you may need to tidy up its name, and possibly (for some applications, and once you are confident that it is working) delete the original.
Copying from a piece of working code that I am using:
set oNewRec to convert record oExistgRec to rich
set name of oNewRec to strName
delete record oExistgRec