Hello, I tried it but didn't help. Actually it is not pasting my content, so I guess that the function is not correct. Sorry, I am not a developer and I am confused using Script Editor
I have uploaded a dictionary screenshot.
Thanks
Hello, I tried it but didn't help. Actually it is not pasting my content, so I guess that the function is not correct. Sorry, I am not a developer and I am confused using Script Editor
I have uploaded a dictionary screenshot.
Thanks
Please post the exact script you used in the Script Editor, Put it in a forum Code Block.
I did not give you the full script above; only the changes. So, to be clear, here's the full script:
tell application "Airmail 3"
set oMsg to selected message
(*
If the above fails, try this:
set msgList to selection
set oMsg to item 1 of msgList
*)
tell oMsg
--- sender property should be in this format ---
-- "Sender Name <name@domain.tld>"
set senderStr to sender
--- Separate sender into Sender Name and Address ---
set AppleScript's text item delimiters to {" <", ">"}
set oSender to text items of senderStr
set senderName to item 1 of oSender
set senderAddr to item 2 of oSender
end tell
end tell
return senderName
Note that it does NOT paste anything. It simply returns the senderName to the Script Editor Event Log (which you may need to enable).
Run this in Script Editor.
If it fails, then please post:
When you are viewing the AirMail scripting Dictionary, enter "message" into the search box, and then screen capture the results.
Hello, I tried all the options and these are the error messages I got:
set oMsg to selected message
error "Can’t get item 2 of {"kmforum@forum.keyboardmaestro.com"}." number -1728 from item 2 of {"kmforum@forum.keyboardmaestro.com"}
set msgList to selection
error "Airmail 3 got an error: Can’t get selection." number -1728 from selection
set oMsg to item 1 of msgList
error "The variable msgList is not defined." number -2753 from "msgList"
I am not that fluent here with Keyboard Maestro, but I use Text Expander to respond to a customer with fill ins, on the Mac and in Windows, not sure if that would be any easier. I find this works great for responding to customer in regards to a quote, see below.
Re: RFQ %filltext:name=Machine Model% Jamestown Machinery
%key:tab%%key:tab%%key:tab%%key:tab%%key:tab%
Hi %filltext:name=person%,
Good %fillpopup:name=Salutation:Morning:Afternoon:Evening%, per your request on the %filltext:name=Machine Model%, %fillpopup:name=RFQ:default=please see attached proposal, pictures, and videos.:please see attached proposal and pictures.:this machine has recently been sold, sorry.:please see attached proposal.:this machine has recently been taken off the market, sorry.%
%fillpopup:name=RFQ Option_1:default=:However we do have a really nice,% %filltext:name=Optional Machine Model:default=% %fillpopup:name=RFQ Option_2:default=:could that work for you?%
%fillpopup:name=RFQ Option_3::Let us know, if that doesn’t work I can check with my colleagues here, to see what they are working on.%
OK, I think I've done about all I can do without an actual copy of the AirMail 3 app.
But good news! I have been able to obtain a copy of the AirMail 3 Beta. So I will use that.
For anyone interested, download the beta here:
https://rink.hockeyapp.net/apps/84be85c3331ee1d222fd7f0b59e41b04
That's the official beta site provided to me by the Airmail support chat.
I'll get back to you soon.
Yes, but I hate the AirMail 3 scripting model. It makes very hard something that is very easy with every other email app I know.
So, AFTER you reply to the inbound email (your customer's email), run this script to get the sender's name:
tell application "System Events"
tell application process "Airmail 3" -- "Airmail Beta" in my case
tell window 1
tell scroll area 1
tell text field 1
set toRecipStr to (its value of item 1 of static text)
end tell
end tell
end tell
end tell
end tell
set AppleScript's text item delimiters to {" <", ">"}
set oToRecip to text items of toRecipStr
tell oToRecip
set toNameStr to item 1
set toAddressStr to item 2
end tell
return toNameStr
Now, let's put that in nice KM Macro.
Start by selecting the inbound email you want to reply to.
Please let us know if this works for you.
~~~ VER: 1.0 2018-05-31 ~~~
Reply to AirMail 3 EMail with Custom Message [Example].kmmacros (6.2 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.
Macro/Script Author: @JMichaelTX
HOW TO USE:
SETUP:
REFERENCE:
This macro built in response to this topic/post:
Topic Title: Insert Airmail receiver's name
URL: Insert Airmail receiver's name
Date: 2018-05-28
Author: retroriff
It works like a charm! I'm totally impressed by the great help I received from you, and also by the powerful features KB has.
Just one little question to make this script even better. How could I just pick up the first name of the sender, instead of the full name? I would like to reply:
Hello Mick
instead of:
Hello Mick Jagger
Thank you very much!
JMichaelTX https://forum.keyboardmaestro.com/u/jmichaeltx
May 30
retroriff:
Hello, I tried it but didn't help. Actually it is not pasting my content,
so I guess that the function is not correct. Sorry, I am not a developer
and I am confused using Script Editor
Please post the exact script you used in the Script Editor, Put it in a
forum Code Block
https://forum.keyboardmaestro.com/t/how-to-paste-script-or-text-in-a-code-block/10091
.
I did not give you the full script above; only the changes. So, to be
clear, here's the full script:
tell application "Airmail 3"
set oMsg to selected message
(*
If the above fails, try this:
set msgList to selection
set oMsg to item 1 of msgList
*)
tell oMsg
--- sender property should be in this format ---
-- "Sender Name name@domain.tld"
set senderStr to sender
--- Separate sender into Sender Name and Address ---
set AppleScript's text item delimiters to {" <", ">"}
set oSender to text items of senderStr
set senderName to item 1 of oSender
set senderAddr to item 2 of oSender
end tell
end tell
return senderName
Note that it does NOT paste anything. It simply returns the senderName to
the Script Editor Event Log (which you may need to enable).
Run this in Script Editor.
If it fails, then please post:
When you are viewing the AirMail scripting Dictionary, enter "message" into
the search box, and then screen capture the results.
Replace:
return toNameStr
with
set posSpace to offset of " " in toNameStr
if (posSpace > 1) then
set firstNameStr to text 1 thru (posSpace - 1) of toNameStr
else
set firstNameStr to toNameStr
end if
return firstNameStr
Hello, I tried that but it didfn't work to me. Here's my macro:
Keyboard Maestro 8.2.1 “Reply to AirMail 3 EMail with Custom Message [Example]” Macro
Reply to AirMail 3 EMail with Custom Message [Example].kmmacros (6.5 KB)
Please be more specific. Exactly how "it didfn't work"?
Errors? Post exact error msg.
Unexpected results? Post expected and actual results.
Sorry, I checked my code and tried it again and now it works.
This macro will be very helpful.
Thank you.
Some great and useful work here. I got some information over on automationorchard.com.
That enabled me to start a new email with a KM variable as a subject.
I'm now using this macro too (the modified one with the first name only). How would it be modified to take the full name of the sender and add that to a variable, and also to add the sender's email address to another variable? As I understand it, the modification to get the first name has meant that the full name isn't available anymore? (I really don't understand applescript!)
Thanks
OK, here's a more flexible macro/script that will return all of the sender's info, comma-delimited, into one KM Variable, which will work like an array:
FirstName,Full Name,Email address
Just replace the entire script in my above macro with this script:
property ptyScriptName : "Get ToRecipient Name of AirMail Outbound Message"
property ptyScriptVer : "2.2" -- Return All Recipient Info as CSV List
property ptyScriptDate : "2018-06-13"
property ptyScriptAuthor : "JMichaelTX"
(*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RETURNS: |text| Name of Sender of Inbound Msg, now the To Recipient of the Reply Message.
PURPOSE/METHOD:
• How To Use
• Reply to an Inbound Message for which you want the Sender's Name
• Then trigger this script.
• Because the Airmail scripting model does not expose the sender's name property, or a reference to a new reply message, we must resort to UI scripting to get the sender's name, from a reply window.
REQUIRED:
1. macOS 10.11.6+
2. Mac Applications
• Airmail 3 OR Airmail Beta
TAGS: @Lang.AS @SW.KM @SW.Airmail @CAT.EMail @CAT.Messages @Auth.JMichaelTX
REF: The following were used in some way in the writing of this script.
1. Airmail Beta app
https://rink.hockeyapp.net/apps/84be85c3331ee1d222fd7f0b59e41b04
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*)
tell application "System Events"
tell application process "Airmail 3" # "Airmail Beta" OR "Airmail 3"
tell window 1
tell scroll area 1
tell text field 1
set toRecipStr to (its value of item 1 of static text)
end tell
end tell
end tell
end tell
end tell
set AppleScript's text item delimiters to {" <", " <", "<", ">"}
set oToRecip to text items of toRecipStr
tell oToRecip
set toNameStr to item 1
set toAddressStr to item 2
end tell
set posSpace to offset of " " in toNameStr
if (posSpace > 0) then
set firstNameStr to text 1 thru (posSpace - 1) of toNameStr
else
set firstNameStr to toNameStr
end if
set scriptResults to {firstNameStr, toNameStr, toAddressStr}
set AppleScript's text item delimiters to ","
set scriptResults to scriptResults as text
return scriptResults
So now you could have:
TO: %Variable%Local__AirMailRecipient[2]%
EMail: %Variable%Local__AirMailRecipient[3]%Hello %Variable%Local__AirMailRecipient[1]%, thanks for contacting us.
Note I have change the output of the Execute AppleScript
from: Local__ToRecipName
to: Local__AirMailRecipient
Questions?
Thanks again @JMichaelTX. One more question. Sometimes the RecipName is not defined and this is an example of what the script returns:
Hello <gezdeojsgiyxymzzgy2tmml4gqydsnjwg42hy@reply.domain.com,
Is it possible to filter recipients who have not been defined, or exclude email addresses?
Thank you
Glorious. This is why I love KM and these forums. Those of us that don't use apple mail (if that's what it's called still) were missing out on a lot of potential workflows. Many thanks.
I would just do that in the KM Macro, after you have received the results from the AppleScript.
If you use the last script I posted, if there is no recipient name, then you should get a result like this:
,,somename@reply.domain.com
Sorry, I used the last version but I get a blank result:
TO:
EMail:
Hello , thanks for contacting us.
Here's my macro:
Insert Text by Pasting.kmactions (511 B)
Thanks
You uploaded just one Action, not your entire Macro.
You must first select the Macro in the Macro panel, then export/share.
IAC, I would need to see a screenshot of the header part of the Airmail message you are replying to. Or even better, do a manual forward of the message, and get s screenshot of the part which shows the sender's name/address.
Hi,
This has stopped working for me also. Here's a screenshot of the header as I can see it from airmail.
I don't know if this raw source excerpt helps? I've xxx'ed out some details in case of web crawlers (I really don't know the etiquette or best practice with that, but I've done it anyway). This did work when I first tried it.
Return-Path: damianevans74@xxx.com
Received: from Damians-MacBook-Pro.local.mail ([xx.xxx.121.237])
by smtp.gmail.com with ESMTPSA id k7-v6sm7814259wrq.82.2018.06.23.11.12.57
for damian@damianxxx.net
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Sat, 23 Jun 2018 11:12:57 -0700 (PDT)
Sender: Damian Evans damianevans74@xxx.com
Date: Sat, 23 Jun 2018 19:12:26 +0100
From: Damian Evans damian@damianxxx.net
To: Damian Evans damian@damianxxx.net
Message-ID: etPan.5b2e8da8.4ac5673.3ca0@damianxxx.net
Subject: Test email
X-Mailer: Airmail (481)
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="5b2e8da8_46a7053e_3ca0"
--5b2e8da8_46a7053e_3ca0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
This is a test email to myself.
=E2=80=94=E2=80=94
Damian Evans
Keyboard Maestro Actions.kmactions (5.5 KB)