Applescript: change group from global inbox to specific database

Hi there,

I’m currently using the Apple Script that fetches my mails from the “Mail”-App.
Unfortunately, all mails go into the global inbox of Devothink.
Is there a possibility to change that into e.g. the database “E-Mails”?

Thanks in advance!

That’s of course possible but which script do you actually use? E.g. the source code would be useful.

I’m currently using this one:

-- Mail Rule - Add messages to DEVONthink
-- Created by Christian Grunenberg on Mon Apr 19 2004.
-- Copyright (c) 2004-2020. All rights reserved.

-- this string is used when the message subject is empty
property pNoSubjectString : "(no subject)"

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			repeat with theMessage in theMessages
				try
					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
					if theSubject is equal to "" then set theSubject to pNoSubjectString
					tell application id "DNtp"
						set theRecord 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 incoming group
						perform smart rule trigger import event record theRecord
					end tell
				end try
			end repeat
		end tell
	end perform mail action with messages
end using terms from

Change

create record within incoming group

to

create record within (incoming group of database "DatabaseName")

… or

create record with … in incoming group -- with no database specified
create record with … in inbox
-- Both commands target the Global Inbox

… or

create record with … in (root of database "DatabaseName")

… or

set theGroup to display group selector
create record with … in theGroup

… or

set theGroup to (get record with uuid "x-devonthink-item://…") -- Pasting the item link of the group
create record with … in theGroup
2 Likes

Thanks a lot, worked fine for me!

You’re welcome :slight_smile:
Which option did you choose?

I chose that one:

create record with … in (root of database "DatabaseName")

1 Like

Gotcha. Well, I hope the other options are clear to you as well :slight_smile:

Yap, more or less :smile:
The „Root“-option is fine for me.