Skip to content

IvanCampos/agents / skills/mailapp-send-email

mailapp-send-email

Verified

Send emails through the macOS Mail app using AppleScript. Use when a task requires composing or sending email via Mail.app (including to/cc/bcc, subject, body, or attachments), or when the user asks for Mail app automation or osascript-based email sending.

FileKindSize
SKILL.mdskill md1.7 KB
agents/openai.yamlconfig245 B
scripts/send_mail.applescriptother3.2 KB

scripts/send_mail.applescript

View on GitHub
on run argv
	set toList to ""
	set ccList to ""
	set bccList to ""
	set subjectText to ""
	set bodyText to ""
	set attachList to ""
	set sendNow to true

	set argc to count of argv
	set i to 1
	repeat while i <= argc
		set argKey to item i of argv
		if argKey is "--send" then
			if i + 1 > argc then error "Missing value for --send"
			set sendVal to item (i + 1) of argv
			if sendVal is "true" then
				set sendNow to true
			else
				set sendNow to false
			end if
			set i to i + 2
		else if argKey starts with "--" then
			if i + 1 > argc then error "Missing value for " & argKey
			set val to item (i + 1) of argv
			if argKey is "--to" then
				set toList to val
			else if argKey is "--cc" then
				set ccList to val
			else if argKey is "--bcc" then
				set bccList to val
			else if argKey is "--subject" then
				set subjectText to val
			else if argKey is "--body" then
				set bodyText to val
			else if argKey is "--attach" then
				set attachList to val
			end if
			set i to i + 2
		else
			set i to i + 1
		end if
	end repeat

	if toList is "" then error "--to is required"
	if subjectText is "" then error "--subject is required"
	if bodyText is "" then error "--body is required"

	set toAddresses to my splitByComma(toList)
	set ccAddresses to my splitByComma(ccList)
	set bccAddresses to my splitByComma(bccList)
	set attachmentsList to my splitByComma(attachList)

	tell application "Mail"
		set newMessage to make new outgoing message with properties {subject:subjectText, content:bodyText & return & return, visible:true}

		repeat with addr in toAddresses
			if addr is not "" then
				make new to recipient at end of to recipients of newMessage with properties {address:addr}
			end if
		end repeat

		repeat with addr in ccAddresses
			if addr is not "" then
				make new cc recipient at end of cc recipients of newMessage with properties {address:addr}
			end if
		end repeat

		repeat with addr in bccAddresses
			if addr is not "" then
				make new bcc recipient at end of bcc recipients of newMessage with properties {address:addr}
			end if
		end repeat

		repeat with aPath in attachmentsList
			if aPath is not "" then
				try
					make new attachment with properties {file name:POSIX file aPath} at after the last paragraph of content of newMessage
				on error errMsg
					error "Attachment failed for: " & aPath & " (" & errMsg & ")"
				end try
			end if
		end repeat

		if sendNow is true then
			send newMessage
		end if
	end tell
end run

on splitByComma(inputText)
	if inputText is "" then return {}
	set oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ","
	set parts to text items of inputText
	set AppleScript's text item delimiters to oldDelims
	return my trimEach(parts)
end splitByComma

on trimEach(listItems)
	set trimmed to {}
	repeat with itemValue in listItems
		set end of trimmed to my trimText(itemValue as text)
	end repeat
	return trimmed
end trimEach

on trimText(t)
	set whiteSpace to {" ", "\t", "\r", "\n"}
	repeat while t begins with " " or t begins with "\t" or t begins with "\r" or t begins with "\n"
		set t to text 2 thru -1 of t
	end repeat
	repeat while t ends with " " or t ends with "\t" or t ends with "\r" or t ends with "\n"
		set t to text 1 thru -2 of t
	end repeat
	return t
end trimText
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall