<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">I have an AppleScript that I believe originally came from <a href="https://www.macsparky.com">MacSparky</a>, that is triggered by Textexpander and works in Mail.app to read the recipient’s first name and automatically populate this in the message body.</p>
<p dir="auto">The script is:</p>
<pre style="border:thin solid gray; margin-left:15px; margin-right:15px; max-width:90vw; overflow-x:auto; padding:5px"><code>tell application "System Events"
tell process "Mail"
tell text field "To:" of window 1
if UI element 1 exists then
set theToRecipient to (value of UI element 1)
if ((count words of theToRecipient) is greater than 0) and (theToRecipient does not contain ",") then
return word 1 of theToRecipient
else if ((count words of theToRecipient) is greater than 0) and (theToRecipient contains ",") then
return word 2 of theToRecipient
end if
end if
end tell
end tell
end tell
</code></pre>
<p dir="auto">I’m not an AppleScript guru, so I was wondering if anybody can advise if there is a way to adjust this script to work within MailMate? And if so, how to go about it?</p>
<p dir="auto">Thanks so much,<br>
Andrew</p>
<hr>
<p dir="auto">Andrew Canion<br>
<a href="https://www.andrewcanion.com">andrewcanion.com</a></p>
</div>
</div>
</body>
</html>