OK --- I created a python script (called quickmessage.py) that can be invoked directly from Alfred. You need Python3 installed on your Mac. The script is below. Adjust it to suit your own server settings, etc You can invoke it from Alfred using the /bin/bash object with the following argument.
/path/to/quickmessage.py -r <sender email address> -s <subject> -m {query}
So I typically create different workflows with the desired sender email address and subject hard coded.
I would still like to know how I can invoke this from Alfred but using a contact name instead of an email address so that I can just use a single workflow for everyone.
------Python script below------
#!/usr/bin/env python3 #Edit these for your own server smptServer = 'your mail server here' sender = 'your own email address here' username = "your username here" password = "your password here" import sys import argparse from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption) from email.mime.text import MIMEText parser = argparse.ArgumentParser(usage = "echo <content> | quickmessage -s <subject> -r <recipient>" ) parser.add_argument("-r", "--recipient", required = True, help = "Email address of person to whom you want to send the message") parser.add_argument("-s", "--subject", required = True, help = "Subject line of the message") parser.add_argument("-m", "--message", required = True, help = "The contents of the message you want to send") args = parser.parse_args() subject = args.subject recipient = args.recipient body = args.message try: theMessage = MIMEText(body, "plain") theMessage['Subject'] = subject theMessage['From'] = sender # some SMTP servers will do this automatically, not all theConnection = SMTP(smptServer) theConnection.set_debuglevel(False) theConnection.login(username, password) try: theConnection.sendmail(sender, recipient, theMessage.as_string()) print ("Mail sent") #Show this in notification center if you want finally: theConnection.close() except Exception as e: print ( "Unable to send email message: " + str(e) ) sys.exit( "Unable to send email message: " + str(e) )