Devonthink: Mail script: Add attachment to DT

Hi there,

I am setting up the Add Attachment script in Mail.
When I test it I find that it adds the attachment to DT as desired, BUT it also generates a copy of the message in DT (with inline attachment). I only want the attachment in this instance, and expected to use the File Message and Attachment for adding both in one shot.

Is there something I can do to stop the Add Attachment script from creating two DT entries?

No bug. There are a variety of scripts available, one of which should do what you need

I’m trying to modify the script to work with “Microsoft Outlook”.

Can you provide assistance?

If I run the Add message(s) & attachments to DEVONthink.scpt from the Apple Mail app, it works perfectly.

I’d like to get it to work with Microsoft Outlook, since that is my primary email application.

On a side note, maybe I should start to use Apple Mail instead?

Apple Mail does provide the tightest integration with Pro Office, in general (ie. not necessarily relate to the scripts you are referring to).

Is it possible to update the Add message(s) to DEVONthink.scpt script so that it keeps the tags that I’ve assigned to an email?

One thing that I loved about MS Outlook was that I could assign a category to an email. That made it easy to search my emails based on category. Apple Mail doesn’t have that, but I have been demoing Mail Tags, and it is working great.

The problem I currently have though is if I tag an email, and then import it into DTPO, the tag doesn’t carry over.

I looked at the script, and this is the part where the variables are assigned for Date, Subject, etc:

			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

This part is where we’re telling DTPO to create item using the value from the variables defined above:

			tell application id "DNtp" to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string), unread:(not theReadFlag)} in theGroup

So my question is what is the mail tag equivalent in Apple Mail, and the tag in DTPO to make the update?

Thanks in advance!

There is no mail tag equivalent in Apple Mail. According to the MailTags quick start, there may be info written in the headers but it’s not something Apple Mail controls (and is not supported by Apple Mail either).

From the MailTags guide:

Tags in DEVONthink are just tags of some record.

Where are the scripts in Korm’s post found?

The Script menu in the menubar while you’re in

If it’s not showing open /Applications/Utilities/Script Editor and turn on the option in its Preferences > General > Script Menu.
Screen Shot 2017-01-22 at 8.36.27 PM.png

Is there a way to add this to the mail toolbar? It’s such a useful script that quick access would be great.


No. Mail’s toolbar cannot be customized – you cannot add scripts there.

You might consider getting FastScripts, with which you can give the script a keyboard shortcut.

Thanks, I’ll have a look at that


MailTags stores that tags in the file system metadata “Tags” for the email message .emlx file (and is visible to Finder and any Spotlight apps), though it doesn’t write any tags to the attachment files. Is there a way to get DT to import the mail messages at the file level so that it would include the Tags?

I believe I will start at new thread to actually discuss MailTags.