Installed the update - can not import mail&attach from mail

Not sure what I did wrong.

After the update today I can not use the script “Add messages & attachments to Devonthink” in Apples Mail.

Get the error message: Mail got an error: AppleEvent handler failed.

Sucks to be a newbie! Still love the Devonthink system just not so good with it yet.

No problems here. Perhaps try re-installing the mail plugin by going to:
DEVONThink Pro Office>Install Add-Ons
ensure mail plug-in is checked, and confirm the installation.

Yup, that helped! Now it works fine again.

Thanks. :smiley: :smiley:

Glad to hear that resolved your issue!

Cheers,
S

Hi there, I have the same problem.
I can’t use the rule at Apple Mail to import only mail attachments to my DEVONthink.

I tried to explain my issue with my attached images :slight_smile:

PS: I’m not able to reinstall the Apple Mail Plugin - resp. I don’t know how

See here

Thanks @Blanc I went through the routine. But now there are no documents imported to DT.
So I’m executing my Mail Script but there are no documents in my inbox of DT.
Before this routine a few AppleScripts worked as expected (as you can see at my screenshots posted earlier).

Does it work if you use the menu entry (add mail to DEVONthink” it’s called, I think)?

No, unfortunately not.
It’s called “Mail rule - add messages to DEVONthink”. But also with this type of AppleScript there is no document input at DT3.

No, I meant in Mail, in the menu select “Message/Add to DEVONthink 3” - does that work? I’m aware that isn’t what you’re trying to do, it’s just part of trouble shooting.

Also, in System Settings, Security and Privacy, Automation, is Mail allowed to control DEVONthink 3?

Ah okay, got it, thanks :slight_smile:

Yes, when I’m clicking on the sub menu at “add to DEVONthink” I get the sorter from DT and I am asked where to put the mail. And then I can directly see the mail at DT.

At System settings, everything is activated :+1:

Ok, so I’ve just sat down at home to try this - and I can confirm it does not work. It will work once the attachment has been opened from Mail once.

@cgrunenberg the script in question sets theFolder to a folder which in my tests is initially empty; I can see the attachment inline in the Mail, but only once it has been manually opened is it placed in the temporary folder (and only then does the script work). Is there any way to adapt the script to trigger Mail to get/download the attachment to theFolder without having to manually open the attachment?

I really like the community here and the quick response! :slight_smile:
Thank you @Blanc

Unfortunately with attachments which has been opened before I can’t send the attachment to DT with own created apple mail rules (“Mail rule - add messages to DEVONthink”).

1 Like

Certainly not automatically, no; I’ll sit down later this evening and see if I can find anything in Mail’s AppleScript directory which would cause Mail to put the attachment in the temporary folder without manually opening it (@pete31 I wonder if you have any ideas off hand?)

Nope.

Ok, at least that made me laugh at the futility of my quest :crazy_face:

so, here goes:

-- Mail Rule - Add attachments to DEVONthink
-- Created by Christian Grunenberg on Fri May 18 2012.
-- Copyright (c) 2012-2020. All rights reserved.

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			set theFolder to (POSIX path of (path to temporary items))
			repeat with theMessage in theMessages
				set theSender to the sender of theMessage
				repeat with theAttachment in mail attachments of theMessage
					try
						-- if downloaded of theAttachment then
						set theFile to theFolder & (name of theAttachment)
						tell theAttachment to save in theFile
						tell application id "DNtp"
							set theAttachmentRecord to import theFile to incoming group
							set URL of theAttachmentRecord to theSender
							perform smart rule trigger import event record theAttachmentRecord
						end tell
						-- end if
					end try
				end repeat
			end repeat
		end tell
	end perform mail action with messages
end using terms from

What I have done is to comment out the downloaded condition. It would seem Mail is reporting the attachment has not been downloaded, so that Christian’s script breaks off at that point. However, for me anyway, the attachment is available to be saved - after commenting out the condition the script/rule works as expected. If the attachment really isn’t available I would assume that would have no further negative impact, as the save command is in a try-loop anyway.

In case you are not aware: you can access the script by selecting “Im Finder öffnen” in the last of your images in your original post. That will open the folder containing the scripts; open the script in question, add -- in the two locations (that is before if and end if) and save.

@Blanc you are fantastic! Thank you very much!
I followed your steps and it worked immediately. :partying_face:

1 Like

Well that’s most pleasing :slight_smile:

I tried the comment-out proposal by @Blanc but it doesn’t work for me unfortunately :frowning: I tried it many times, restarted each of the programs.

I’m running 10.15.7 on an intel mac, devonthink 3.6.3

I wonder why there’s a set of scripts named almost the same in Library/Scripts/Applications/Mail which works (but only manually when selecting emails) and starts with tell application "Mail" (not using terms...). I did the same change as to the Script in “Application Scripts/com.apple.mail”