#2715 new
Colin Wirz

Custom bundle paste text into open email

Reported by Colin Wirz | December 21st, 2020 @ 11:13 PM

Is there a way of pasting text into an email when executing a custom command? Currently there is only a "createMessage" action that allows the script to pass a message body to be placed in a new email.

Thanks for the response

Colin

Comments and changes to this ticket

  • benny

    benny December 22nd, 2020 @ 07:42 AM

    If by pasting you mean taking whatever is on the pasteboard (⌘C) and put it into the email body then you can use the pbpaste command to get the pasteboard string. Otherwise, I think I'm going to need a few more details to understand what you are trying to do.

    Here's how you read a value and put it into a variable in Bash.

    str=`pbpaste`
    
  • Colin Wirz

    Colin Wirz December 22nd, 2020 @ 09:22 AM

    Hey Benny im trying to put a tracking image into a email that im responding to or that im creating. Since the email has almost no information before im sending it I would like to add the link by executing a command in my custom MailMate bundle to add it to the current draft email whenever i feel ready (or when im sending the email: that would be even better). Since there is only few commands documented here: https://github.com/mailmate/mailmate_manual/wiki/Bundles#output im not sure how to do this. My current state is this:

    Thanks for your help :)

    newTrackedEmail.mmCommand

    {
        name          = "New tracked email";
        uuid          = "550219B8-6E4E-4C2B-A1F2-1043951C0947";
        keyEquivalent = "@n";
        executionMode = noMessages;
        input         = "canonical";
        output        = "actions";
        environment   = "MM_FROM=${from}\nMM_TO=${to}\nMM_SUBJECT=${subject}";
        command       = '#!/bin/bash\n"${MM_BUNDLE_SUPPORT}/bin/createTrackedEmail"';
    }
    

    createTrackedEmail

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    import sys
    
    # This is needed to avoid breaking code-signing
    sys.dont_write_bytecode = True
    
    import os
    import json
    
    requests_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'vendor')
    sys.path.append(requests_dir)
    
    import requests
    
    response = requests.post('http://localhost:8875/backend/api/pt/create/', {
        'account': os.environ.get('MM_FROM'),
        'email': os.environ.get('MM_TO'),
        'subject': os.environ.get('MM_SUBJECT'),
    })
    
    result = {
        'actions': [
            {
                'type': 'createMessage',
                'body': '![]({})'.format(response.json()),
                'resultActions': [
                    {
                        'type': 'openMessage',
                    }
                ]
            }
        ]
    }
    
    print(json.dumps(result))
    
  • benny

    benny December 22nd, 2020 @ 09:39 AM

    • State changed from “new” to “accepted”

    Ok, if I understand correctly then you need to trigger a bundle command when sending an email. That is not currently possible.

    You also need to put a Markdown image link into the message referencing your tracking image. That part should work (similar to what is generated when you drag an image into the composer).

    In other words, currently the best you can do is to have separate openMessage and replyMessage bundle commands inserting a link on creation.

    (Note that MailMate and many other email clients block tracking images by default. It might not be worth the effort even if you have good reasons to use tracking URLs.)

    I'll put the ticket into the “accepted” state for the request of a send-message-event for bundle commands. Don't expect it soon though.

  • Colin Wirz

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Mac OS X email client.

Shared Ticket Bins

People watching this ticket

Pages