Custom Time Send Later with Apple Mail
This is a macro to send later with Apple Mail using a time that isn't already available in the drop down menu. It GUI scripts the custom time dialog box.
84)Send 2pm today.kmmacros (15 KB)
Custom Time Send Later with Apple Mail
This is a macro to send later with Apple Mail using a time that isn't already available in the drop down menu. It GUI scripts the custom time dialog box.
84)Send 2pm today.kmmacros (15 KB)
Thanks!
That applescript didn't work for me. I got something working using trial and error and a bit of Claude AI .
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Mail" to activate
delay 1 -- Wait for Mail to come to the foreground
tell application "System Events"
tell process "Mail"
-- Find the window with the compose message
set targetWindow to front window
-- Navigate through the UI hierarchy
set toolbarView to first toolbar of targetWindow
set toolbarItemViewer to first group of toolbarView
set sendGroup to last group of toolbarItemViewer
-- Find the schedule button (last menu button in the send group)
set scheduleButton to last menu button of sendGroup
-- Click the schedule button
click scheduleButton
delay 0.5
-- Select "Send Later..." from the dropdown menu
-- We'll try multiple methods to find and click the correct menu item
try
click menu item "Send Later..." of menu 1 of scheduleButton
on error
try
click menu item "Send Later…" of menu 1 of scheduleButton
on error
try
-- If the exact match fails, try to find a menu item containing "Send Later"
set laterItem to (first menu item of menu 1 of scheduleButton whose name contains "Send Later")
click laterItem
on error
display dialog "Could not find 'Send Later...' option. Please check the script." buttons {"OK"} default button "OK"
end try
end try
end try
end tell
end tell
I also created a variable for the minutes and set it to a calculation RAND(10,60)
so when I'm sending a bunch of emails at once they don't all go at the same time.
Doesn't work for me on Sequoia 15.1
I get the following error. Anyone have a solution?
Macro Cancelled
Execute an AppleScript failed with script error: text-script:189:248:execution error: System Events got an error: Can't get toolbar 2 of window 1 of process "Mail". Invalid in...
Try @SteveLambert's AppleScript instead. Or change line 8 of OP's AppleScript from:
click menu button 1 of group 1 of group 1 of toolbar 1
to
click menu button 1 of group 1 of group 1 of toolbar 1
I tried copying @stevelambert's apple script and I get an error.
Just to ensure I'm doing it properly, I created a new action, selected "execute an applescript", then pasted @stevelambert's apple script.
I get the following error:
Macro Cancelled
Execute an AppleScript failed with script error: text-script:473:483: execution error:
System Events got an error: Can't get last group of group 1 of toolbar 1 of window
"Inbox - 6,030 messages, 1 unread" of application process "Mail". Invalid index.
(-1719). Macro "Send Later" cancelled (while executing Execute AppleScript).
You're looking at your Inbox -- AFAIK (I don't use this feature in Mail) these macros are written to be used when you have an outgoing message window at the front. Which makes sense because it will be an outgoing message that you want to "Send Later".
So prepare your new message or reply and, with that message window still active, run the macro.
I tried doing as you said and I still get the error. I have an email lined up to go, activate the keyboard maestro script via a hotkey and then an error
What OS and version of Mail are you running (different versions can have UI elements in different orders), what language is your computer set to (just in case that matters!), and what's the error?
If it's helpful, I just tested it again and it's still working for me.
I'm running:
Apple Mail Version 16.0 (3826.200.121)
MacOS Sequoia 15.1.1 (24B91)
Here's the copy of the applescript I have in there:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Mail" to activate
delay 1 -- Wait for Mail to come to the foreground
tell application "System Events"
tell process "Mail"
-- Find the window with the compose message
set targetWindow to front window
-- Navigate through the UI hierarchy
set toolbarView to first toolbar of targetWindow
set toolbarItemViewer to first group of toolbarView
set sendGroup to last group of toolbarItemViewer
-- Find the schedule button (last menu button in the send group)
set scheduleButton to last menu button of sendGroup
-- Click the schedule button
click scheduleButton
delay 0.5
-- Select "Send Later..." from the dropdown menu
-- We'll try multiple methods to find and click the correct menu item
try
click menu item "Send Later..." of menu 1 of scheduleButton
on error
try
click menu item "Send Later…" of menu 1 of scheduleButton
on error
try
-- If the exact match fails, try to find a menu item containing "Send Later"
set laterItem to (first menu item of menu 1 of scheduleButton whose name contains "Send Later")
click laterItem
on error
display dialog "Could not find 'Send Later...' option. Please check the script." buttons {"OK"} default button "OK"
end try
end try
end try
end tell
end tell
And I exported the full macro I'm running just in case it's helpful:
Send 1pm-ish today.kmmacros (15.9 KB)