Importing mails & attachments

I’m importing mails with attachments running (from Mail) the script “Add messages(s) & attachments to DEVONthink” (actually a slightly modified version).

In importing the mail DTPO removes the attachments; that’s OK to save space since the attachments are already saved in the group purpose-created by DTPO.

The problem is the way attachments are shown in the saved mail:


  1. A sort of dead link is left that tricks other apps (e.g. if you try to convert the .eml file to pdf using Email Archiver)

  2. The filesize of the attachments is shown to be 0KB so you loose a part of the information contained in the original mail (e.g. if you want to forward it)

The solution could be to substitute the links with a simple text list of the attachments showing the right filesizes.
A nice touch would be to add SHA1 hash for each attachment.

Is the attachment missing, or are you looking at the text alternative view? There are two views available for email imported to DEVONthink. In one view, the “best alternative” view, attachment links are not active. The toolbar above that view looks like this:

In the “text alternative” view the links are active and the toolbar looks like this

The icon under the red pointer is a toggle.

Previous screenshot was taken in Text alternative view.
Here’s what it’s shown in Best alternative view mode:


If I double click on one of such links my system tries to open the attachment with the default app (Acrobat for PDF in my case):


My understanding is that DTPO removes the attachments but “forget” to remove (or better substitute) the links.

Anyone else seeing that behaviour or is it my Mac?

I have never experienced DEVONthink removing attachments from email imported by script or by File > Import > Email.

I’m not using the File > Import > Email… command.

I’m using the script “Add message(s) & attachments to DEVONthink” that get installed in ~/Library/Scripts/Mail (as I wrote I’m actually using a slightly modified version)
The script imports the mail (.eml file), creates a new group (named after the mail subject) and saves the attachment(s) in that group.
Since the goal of the script is to have your attachments saved in a group, it was clear to me that the removal of the attachments was made intentionally to save disk space.
Now I’m not so sure any longer.

I deleted the original script so I cannot test it (how can I install it again? It’s not included in the extras that come inside installation .dmg).

Those script are installed by choosing DEVONthink > Install Add Ons… > Applications Scripts. They are installed in ~/Library/Scripts/Applications/Mail. The originals are distributed inside the DEVONthink application package, but using Install Add Ons… should make it unnecessary to extract the scripts from that package.

Thanks Korm.
Unfortunately I get the same result with the standard script as well.

Have you ever tried to import a mail (with attachments) using the script in object?
I think I’ll open a support request.

I’m using basically the same script for a long time and have never seen that behaviour. Also to my knowledge there is no script from DEVONtechnologies to strip the attachments from the email, if you want to do this, you would have to do so from within Apple Mail (menu bar > Message > “remove attachments”).

Also there is nothing in the original script, that would remove the attachments and I just ran the original script here and the attachments (tested with .pdf etc) are imported fine as a file as well as within the .eml… No icons with questionmark and they open from within the .eml correct (tested with Acrobat, Skim and Preview). [DtPO 2.5.1, OS 10.8.3]

The purpose of this script is to import the attachments additional to the .eml (that still contains it), so that you don’t have to add it manually in a second step. The origin for that is, that DEVONthink Pro Office does not index attachments within .eml-files - a feature that may come with future versions.

PS: The actual version of the script is named “Mail Rule - File messages & attachments.scpt” and is installed - since OS 10.8. - in ~/Library/Application Scripts/

Any idea why some scripts are installed in that folder and others in ~/Library/Scripts/Applications/Mail?

That location was the standard path for Mail Scripts (not only from DEVONtechnologies) prior to OS 10.8… If you let DEVONthink Pro Office install all scripts for Apple Mail again, no scripts will be installed there anymore.

PS: I’m not sure, why Apple has changed or at least added that and if it’s limited to some applications. The old path is still used to access scripts from the script menu in the menu bar.

I think we’re speaking of two different scripts (though I checked the codes and they’re essentially the same when it comes to .eml record creation).

I’m using the script that you manually launch from the menubar script menu (the name is “Add message(s) and attachments to DEVONthink”).
Try selecting a mail with attachments in Mail and launch the script.

The attachments are not “technically” stripped; I think they’re simply not “transferred” to the new DTPO record (the .eml file).
That file is created with the property “the source” from Mail. That property (according to Mail dictionary) is a text so I cannot see how it can include files attached to the mail.
It can include the link (text) to that files but the link gets broken when the content is used to create DTPO record.

I’m not an expert but that’s my guess.
I opened a ticket and I’m waiting the reply form DevonTech.

When updating to DtPO 2.5.1 scripts dated 2013-03-07 were installed in both locations.

If script menus can’t access scripts in the new location that would be a reason for having those that need to in the old location.

I beg your pardon, you’re right! I got confused with another folder called “Mail” in ~/Library/Scripts instead of the one in ~/Library/Scripts/Applications. :blush:

Over here on 10.8.3 if I delete the scripts from ~/Library/Scripts/Applications/Mail and have DEVONthink reinstall “Applications Scripts”, as I wrote above, then the Mail scripts are newly installed into ~/Library/Scripts/Applications/Mail.

For me, all four scripts work exactly as their names imply – and in the three scripts where the message(s) is/are supposed to be copied, then they are … and the copied message(s) in the database always have attachments included in the message. I’m not seeing the case that the OP reported.

Thank you for making clear, what script you use exactly. I ran the same script from the menubar on some messages and - like korm - I cannot reproduce the problem here. The .eml in DEVONthink Pro Office correctly holds and shows the attachment (pdf tested) and it opens from within the mail fine. Also the attachment is imported separately as a file. Nothing broken here.