Auto-sync: 2026-02-13 13:21:42

This commit is contained in:
Adolfo Reyna
2026-02-13 13:21:42 -05:00
parent 74f9a21c30
commit 047462be4d
3 changed files with 73 additions and 0 deletions

View File

@@ -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}}"

View File

@@ -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

View File

@@ -0,0 +1,19 @@
#!/usr/bin/osascript
on run argv
if (count of argv) < 2 then
return "Usage: send_email.scpt <recipient> <subject> <body>"
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