After messing with a number of options to import my mail, I figured just dragging all the emlx messages is easiest, and doesn’t appear to cause any crashes.
Problem is, now I’m stuck with a bunch of .emlx files - not very descrptive.
With some help from previous forum threads on this here forum, I managed to get a script to convert the names of the items from .emlx to the x paragraph of the content.
This works, but only to some extent. I’ve found that for most emails, the third paragraph is the subject line. But sometimes the 3rd paragraph is the content, or it doesn’t exist.
So I have two questions:
Is it possible to extract the subject line more accurately, perhaps some command other than ‘paragraph’?
If not, is there any way to at least not ‘stop’ the script when it runs into an error ‘paragraph 3 doesn’t exist’.?
I’m very new to applescript, and so far I’m very impressed with it (and DT’s scriptability!)
tell application "DEVONthink Pro"
tell front think window
set curr to selection
repeat with r in curr
set atxt to plain text of r
set aname to third paragraph of atxt
set name of r to aname
Here’s a script to rename emails (or other stuff with a subject):
tell application id "com.devon-technologies.thinkpro2"
set theSelection to the selection
repeat with theRecord in theSelection
set theMD to meta data of theRecord
set theSubject to |kMDItemSubject| of theMD
set name of theRecord to theSubject
The only trick is accessing the meta data. Possible keys are currently kMDItemTitle, kMDItemHeadline, kMDItemSubject, kMDItemDescription, kMDItemCopyright, kMDItemComment, kMDItemURL, kMDItemKeywords, kMDItemCreator, kMDItemProducer, kMDItemAuthors, kMDItemAuthorEmailAddresses, kMDItemRecipients, kMDItemRecipientEmailAddresses, kMDItemEmailAddresses, kMDItemAlbum, kMDItemComposer, kMDItemContributors, kMDItemPublishers, kMDItemEditors and kMDItemOrganizations.
I’ll add this to the description of the script suite.
So, with that metadata I could, say, store the recipients, sender, and date of mail in the comment for the item. Or would it be better to put that somewhere else?
If the comments where to say:
Or even better, I could set the creation date of the item to the send date of the email, right? How would I go about doing that? Would you be willing to help me out on that (setting creation date to email date)?
This information is already stored in the database, see for example Additional Information in the Info panel. And you can search for it by using All or Meta Data options. Therefore I don’t know if there’s a need to add it to the comment.