There are several old conversations that discuss this but without any solution. I’m hoping that over the intervening years someone may have found a way.
Here is what I would like to do:
Save an attachment from an email as an individual item in DevonThink (e.g. via attachment context menu)
Remove the attachment from the email
Add a link to the DevonThink item in the email
I would be happy to do this on a per-email or per-attachment process, rather than bulk-processing many emails (although I could certainly make use of that).
At the moment, the only thing I can do is manually drag and drop the attachments to DevonThink. Then, I need to manually remove the attachments from the email in Mail > Message > Remove Attachments.
Has anyone got any working methods or suggestions?
I doubt that any mail server is prepared to modify emails in situ like you propose here. One way I see:
Copy the content of the email to a new message
append the DT link to the attachment to it
send the new email to yourself
delete the original email.
This may or may not be scriptable, depending also on your email program
I find the whole idea irritating: attachments would only be accessible if the relevant DT database is available on the device you’re currently reading your email with. Which goes against the whole concept of an email server
Emails can be modified: Mail will strip attachments and Thunderbird adds a link to the file in the filesystem. I’m not sure how this is done, whether it’s detached on the server or the original is deleted and replaced with the updated copy of the email.
I just tried that with an e-mail containing only a single attachment (“E-Mail”/“Remove attachments”) in Mail. No apparent change. When I move away from this e-mail and back to it, the attachment is still visible, but the summary says “the attachment has been manually removed”.
Thunderbird doesn’t seem to have any scripting support (except for the default classes). So I’d probably go with the approach described before.
To have documents in DevonThink and to retain the context and history of conversation on email. I know that I can import email into DevonThink but that is not the best way of managing active email conversations.
Email applications will conveniently arrange emails in conversations, which DevonThink won’t. I can also reply when needed in future and pick up the conversation with relevant contacts.
However, DevonThink is where I want to keep the documents included in those conversations as that’s what DevonThink is best at. I no longer need them in the email application where they take up significant space and reduce the email application’s performance.
This isn’t exactly the same issue, but when I drag an email into DT3, I usually also drag the attached file in too (separately) - because then the entire document will show up in searches (and show the occurrences), not just display the email message. In addition to the extra step, the drawback of course is wasted space, roughly doubling storage needed for some files that are often fairly large.
The action to start a smart rule or script (like importing) is irrelevant, any other trigger like ‘Before sync’ would work as well.
It’s obvious DT is aware of the presence attachments, as the meta-data shows a paperclip and counts the number of attachments. So far, so good.
The main question for @BLUEFROG is: would creating a replicate of an existing e-mail attachment be scriptable somehow? I’ve browsed through the Applescript library and didn’t find a suitable reference, but that’s me.
If not: could this be added as a smart rule action? (Which would be a feature request).
Hence my suggestion of creating a replicate of the attachment if possible.
I feel we’re communicating on different ‘wavelengths’ here
Isn’t an attachment or aren’t several attachments an integral part of one e-mail record?
Replicating an e-mail record including the attachment is possible, but how does one separate the attachment from the e-mail and replicate only that attachment?
This is certainly getting nearer, but if I understand the script correctly this duplicates the attachment and doesn’t replicate it, as DT seems to import the attachment:
tell application id "DNtp" to import theAttachment to theGroup
Which will create a new record and not a replicate of the attachment. Might it be that attachments aren’t stored within the eml as a separate record, but as an integral part of the eml record?
Right, that clears up the main question, and perhaps the confusion . If the attachments is part of the eml it’s obviously not possible to create a replicate of the attachment only.
But could this somehow be possible in a future release of DT?
Attachments frequently are a separate document that can be related to the e-mail, but not necessarily. In the latter case e-mail just happened to be the medium that was used to transport a file (the attachment). Loosing the relation between the e-mail and attachment is undesirable, but looking through e-mails to find a specific file is also undesirable.
The idea behind replicating the attachment only, is that attachments needn’t be present twice in a database or several databases as it increases unnecessary redundancy. This is of course why replicates exist (and is one of the reason that makes DT such a nice product IMO).
Perhaps DT could create two or more UUIDs per e-mail, that refer to the e-mail and one or more attachments, but keeps them related while viewing an e-mail. The UUID of the attachment(s) can be replicated (or duplicated if need be) to another group.
Replicating doesn’t support internals of files, it’s highly unlikely that this will ever be possible. Importing the attachments on their own (like the above scripts does or the scripts in the Scripts menu extra for Apple Mail) are the only options currently.