This action fails (silently) for me now. Is this a known issue? An El Capitan thing?
Hey Jack,
This is a known issue, but the fix has not yet been determined.
In the meantime you can script it directly.
-Chris
------------------------------------------------------------
# Auth: Christopher Stone <scriptmeister@thestoneforge.com>
# dCre: 2013/05/15 06:11
# dMod: 2015/10/08 14:33
# Appl: Apple Mail
# Task: Make a new outgoing message.
# Libs: None
# Osax: None
# Tags: @Applescript, @Mail, @Make, @New, @Outgoing, @Message
------------------------------------------------------------
set toName to "John Smith"
set toAddress to "address@null.com"
set _sender to "Christopher Stone <null@null.com>"
set _subject to "Test Message"
set _body to "Now is the time for all good men to come to the aid of their country."
set _sig to "Take_Care"
tell application "Mail"
set _sig to signature _sig
set _msg to make new outgoing message with properties {subject:_subject, content:_body & return & return}
tell _msg
set visible to true
make new to recipient at end of to recipients with properties {name:toName, address:toAddress}
set sender to _sender
set message signature to _sig
end tell
activate
end tell
------------------------------------------------------------------------------------------
Good to know! Thanks.
I have looked in to this and determined it is a bug in Mail’s AppleScript support in El Capitan that is relatively easy to work around.
Basically, Mail does not like having visible set to false and then true.
You can see this in action with the AppleScript:
tell application "Mail"
set newMessage to make new outgoing message
tell newMessage
set visible to false
set visible to true
end tell
activate
end tell
So all I need to do is not set visible to false initially and that will resolve the problem for 7.0.2.
I’ve been struggling with this failure for days and just found this post. I don’t know AppleScript, but I can follow directions if someone could please tell me where to make the AppleScript adjustment to “not set visible to false initially.” Thanks in advance!
You can't change the Keyboard Maestro action. That will have to wait for Peter to make a change in the application itself.
You can only script it directly, as I mention above.
-Chris
Hello, Chris. Thanks for your reply. I’m such a neophyte, I don’t know what you mean by “you can script it directly.” I see what you wrote that I should copy and paste somewhere, but where? In what application? Thanks much!
Sandy
Hey Sandy,
That's AppleScript code. You run it from an execute AppleScript action.
You can edit and run it from the Script Editor app to see how it works, before you put it in an action and run it from Keyboard Maestro.
You can go to YouTube and type in "AppleScript editor" to get a general idea of how it works. As of Yosemite it is called the "Script Editor", because as of then it handles JavaScript and Applescript Objective-C in addition to AppleScript.
-Chris
I use the Send Mail Message action to send an email with an attachment. This week I upgraded to El Cap and ever since, it sends the email but without the attachment, Is that the same bug as described in this thread? Or should I start a separate thread?
–Rick
Hey Rick,
Yes.
-Chris
This is fixed in 7.0.2.
Thanks!
Hi,
7.0.2. did not fix this problem for me!
Thomas
7.0.2 does not fix my problem. The Send Mail action still works to send an email but it does not include the specified attachment.
If 7.0.2 does not fix the problem you will need to email support (support@stairways.com) with the action you are using so we can see what the issue is.
Is there a way if you are already replying to an email to choose the email that it replies from? I have several and would like to switch between those. I use to be able to do this through the OS but that no longer works for me.
Keyboard Maestro only seems to be able to start a new email from scratch and I would like to assign a keyboard shortcut to each of my 15 email accounts I use. The order seems random and has been for the past 10 years so I have to set different work arounds for each computer I use to select these so it is not efficient or very practical.
set _sender to "Christopher Stone <null@null.com>" -- Adjust to match the account name in Mail preferences
set _sender to "Christopher Stone - null@null.com" -- Adjust to match the account name in Mail preferences
set _sender to "null@null.com" -- Adjust to match the account name in Mail preferences
tell application "Mail"
try
-- Get the frontmost outgoing message (reply, forward, or new message)
set frontMessage to outgoing message 1
-- Verify the sender is valid
set availableSenders to sender of accounts
if _sender is not in availableSenders then
error "The specified sender account is not available. Please check the account name."
end if
-- Change the sender of the frontmost outgoing message
set sender of frontMessage to _sender
on error errMsg
display dialog "Error: " & errMsg
end try
end tell
It's easiest to target an outgoing message
is if you script the creation of that message as well:
tell application "Mail"
set theMsg to item 1 of (get selection)
set theReply to (reply theMsg)
set sender of theReply to "my_name@account.touse.com"
end tell
That way you don't have to rely on it being the frontmost.
But if you've already started the reply and then want to change the sending account (and can rely on the email being frontmost):
tell application "Mail"
set sender of outgoing message 1 to "my_name@account.touse.com"
end tell
Note that you can also use System Settings->Keyboard Shortcuts->App Shortcuts to give each item in the "From" pop-up it's own Shortcut. IIRC the trick is to use an em-dash as the separator in the menu item name.
Thank you for these two AppleScripts. For some reason I couldn't get the second one to work which is what I usually want to do but the first one is very helpful.
Thanks that pointed me in the right direction where things weren't working. For me it is En-dash that works through System Settings which is what I use to use and didn't realize I needed En-dash (option+hyphen)
- Hyphen (-):
This is a simple hyphen, often used for compound words or as a minus sign. - En-dash (–):
Slightly longer than a hyphen, typically used for ranges (e.g., "2020–2024") or to indicate connections. - Em-dash (—):
The longest of the three, used for interruptions in sentences or as a strong separator. (Option+shift+hyphen)
I didn't even know there was a Em-dash until you pointed that out.