76: Automating with Alfred

This is the site I used for my first mailto links :slight_smile:

If you happen to know python, here is some code to generate a link for you. Alfred can run Python. But of course you can use your language of choice. Important is just the function that “quotes” text, ie the % escaping.

import urllib.parse

def generateMailtoLink(to, cc, subject, body):
    
    mailparts = {
        'to': to,
        'cc': cc,
        'subject': subject,
        'body': body
    }

    for key, value in mailparts.items():
        mailparts[key] = urllib.parse.quote(value)
            
    mailToLink = "mailto:{to}?cc={cc}&subject={subject}&body={body}".format(**mailparts)
            
    return mailToLink

If you want to design a workflow, you need to think how you want to handle the input, ie do your want four promt individual prompts for each field (assuming to, cc, subject, body) or do you want one promt, and parse your input into four parts.

I would suggest using four Alfred prompts, storing each part in an Alfred variable and using a script action after the last one to generate a link and adding it to your task manager of choice.

1 Like