From 047462be4ddd0265d9db51d10034ba9733f11f40 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Fri, 13 Feb 2026 13:21:42 -0500 Subject: [PATCH] Auto-sync: 2026-02-13 13:21:42 --- skills/macos-mail/SKILL.md | 12 +++++++++ skills/macos-mail/fetch_emails.scpt | 42 +++++++++++++++++++++++++++++ skills/macos-mail/send_email.scpt | 19 +++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 skills/macos-mail/SKILL.md create mode 100644 skills/macos-mail/fetch_emails.scpt create mode 100644 skills/macos-mail/send_email.scpt diff --git a/skills/macos-mail/SKILL.md b/skills/macos-mail/SKILL.md new file mode 100644 index 0000000..e372363 --- /dev/null +++ b/skills/macos-mail/SKILL.md @@ -0,0 +1,12 @@ +# macOS Mail +Description: Manage emails via the macOS Mail app using AppleScript. Can fetch recent emails and send new ones. + +## Tools + +### fetch +Description: Get the latest N emails from the inbox. +Command: osascript skills/macos-mail/fetch_emails.scpt {{limit}} + +### send +Description: Send an email using the default account in macOS Mail. +Command: osascript skills/macos-mail/send_email.scpt "{{to}}" "{{subject}}" "{{body}}" diff --git a/skills/macos-mail/fetch_emails.scpt b/skills/macos-mail/fetch_emails.scpt new file mode 100644 index 0000000..132c7c1 --- /dev/null +++ b/skills/macos-mail/fetch_emails.scpt @@ -0,0 +1,42 @@ +#!/usr/bin/osascript +on run argv + set messageLimit to 10 + if (count of argv) > 0 then + set messageLimit to (item 1 of argv) as integer + end if + + tell application "Mail" + set output to "" + set inboxMessages to (messages of inbox whose read status is false) + + -- Fallback to all messages if no unread, or just take top N + if (count of inboxMessages) is 0 then + set inboxMessages to messages of inbox + end if + + -- Sort logic is hard in pure AppleScript efficiently, usually they come in order. + -- We'll just grab the first N items which are usually newest. + + set msgCount to count of inboxMessages + if msgCount > messageLimit then + set msgCount to messageLimit + end if + + repeat with i from 1 to msgCount + set msg to item i of inboxMessages + set msgSubject to subject of msg + set msgSender to sender of msg + set msgDate to date received of msg + set msgContent to content of msg + + -- Truncate content if too long + if (length of msgContent) > 500 then + set msgContent to (text 1 thru 500 of msgContent) & "..." + end if + + set output to output & "From: " & msgSender & "\nSubject: " & msgSubject & "\nDate: " & msgDate & "\nBody: " & msgContent & "\n---\n" + end repeat + + return output + end tell +end run \ No newline at end of file diff --git a/skills/macos-mail/send_email.scpt b/skills/macos-mail/send_email.scpt new file mode 100644 index 0000000..4cd19e0 --- /dev/null +++ b/skills/macos-mail/send_email.scpt @@ -0,0 +1,19 @@ +#!/usr/bin/osascript +on run argv + if (count of argv) < 2 then + return "Usage: send_email.scpt " + end if + + set recipientAddress to item 1 of argv + set msgSubject to item 2 of argv + set msgContent to item 3 of argv + + tell application "Mail" + set newMessage to make new outgoing message with properties {subject:msgSubject, content:msgContent, visible:false} + tell newMessage + make new to recipient at end of to recipients with properties {address:recipientAddress} + end tell + send newMessage + end tell + return "Email sent to " & recipientAddress +end run \ No newline at end of file