I get too many newsletters, to read every week and yet some of them contain nuggets. Sometimes I want to read them in the next week and sometimes I want to be able to find again later.
My goal is to summarize each newsletter with GenAI and turn it into a digest, links to each newsletter and bullet points outlining the content. (No turgid AI generated prose).
(My email is handled by Gmail, however I’m in the process of looking for a replacement, so I don’t to link back to Gmail).
Goal
Once a week, produce a digest of the newsletters I’ve received that week.
Current Manual Workflow:
file newsletters into a Gmail folder /WeeklyNewsletters
Once a week:
In AppleMail and drag the newsletters into DEVONthink
In DEVONthink - Select all the newsletters and use an AI to summarize (currently using Gemini 2.5 Pro - it has a large context window and does a good enough job of summarizing the content)
Copy and paste the summaries into Markdown document in Obsidian
Ideally, I would like to automate all of this.
Desired Automations
AppleMail → DEVONthink - AppleMail’s rules only work if the is still in the inbox. Hpw can I automate moving newsletters from /WeeklyNewsletters to DEVONthink?
DEVONthink Summarisation - SmartRules can be triggered once a week. I can’t figure out how to get smart to scan all of the newsletters at the same time and send the output to a Markdown file.
DEVONthink → Obsidian - Export the generated Markdown to file in Obsidian.
I’m not even sure the right place to ask some of these questions
FWIW my current prompt:
Each of the following items as an email newsletter. I would like you to a short markdown summary of each item, linking to the original article in DEVONthink. The link should start with who the newsletter is from; then the subject line.
For each email writing at least one to thee bullet points for each major header.
Use bullet points for each major point in the email. Prefer brevity.
Maybe you could simply use the AppleScript command summarize contents of records ... as text summary to markdown which uses also generative AI (like Edit > Summarize via Chat… or Tools > Summarize Documents via Chat) and supports the custom prompt specified in Settings > AI > Summarization
For scripting Apple Mail you might have a look at the scripts in the folders ~/Library/Application Support/Scripts/Applications/Mail and ~/Library/Application Scripts/com.apple.mail
If you’re already using a mail rule to move the email, why aren’t you also using a mail rule script to import the email into your database? For example…
@BLUEFROG I’m moving emails manually to the WeeklyNewsletters folder. I was trying to say, I can’t rely on Apple Mail rules because they only work on mail in the Inbox.
My first attempt was to list email addresses of newsletters in an AppleMail rule. However, that is fragile.
With the help of Claude Sonnet 4, I mofified one of your AppleScript examples to get the following.
Mt next challenge/question is, what is the best way to get the message into a specific group in a database? I looked around for a DEVONthink Dictionary documentation - both in the TakeControl book and in the help. Neither says where to find a complete list of all commands/operations.
-- Import selected Mail 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)"
tell application "Mail"
try
tell application id "DNtp"
if not (exists current database) then error "No database is in use."
set theGroup to preferred import destination
end tell
-- Get all messages from the WeeklyNewsletters folder
set theFolder to null
repeat with anAccount in accounts
try
set theFolder to mailbox "WeeklyNewsletters" of anAccount
exit repeat
on error
-- Folder not found in this account, continue searching
end try
end repeat
if theFolder is null then error "WeeklyNewsletters folder not found."
-- Get all messages from the folder
set theMessages to every message of theFolder
if the length of theMessages is less than 1 then error "No messages found in WeeklyNewsletters folder."
repeat with theMessage in theMessages
my importMessage(theMessage, theGroup)
end repeat
on error error_message number error_number
if error_number is not -128 then display alert "Mail" message error_message as warning
end try
end tell
on importMessage(theMessage, theGroup)
tell application "Mail"
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 theGroup
perform smart rule trigger import event record theRecord
end tell
on error error_message number error_number
if error_number is not -128 then display alert "Mail" message error_message as warning
end try
end tell
end importMessage
Danke.
…and what is the best way to the messages into a specific group?
And looking at the second part. @cgrunenberg I see “summarize contents of records” in the list of AppleScript commands. I don’t see any examples of how to use it. Nor do I see any information on how feed it a specific LLM prompt.
This command (like e.g. Edit > Summarize via Chat… or *Tools > Summarize Documents via Chat > … *) uses the options in Settings > AI > Summarization but doesn’t support a prompt directly. But you could define a custom prompt for this case in the settings.
Alternatively you could use the command get chat response for message. E.g. create a copy of the template ~/Library/Application Support/DEVONthink/Templates.noindex/AI/_Document Assistant — Markdown.templatescriptd, change the extension to .scptd and open it with the Script Editor.app.