Add functionality to "Send message Task"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Laimonas
    Senior Member
    • May 2021
    • 237

    #1

    Add functionality to "Send message Task"

    Hi there,

    We are missing one functionality, when we use workflow and flowchart "Send Message Task" / "Send mail".
    It would be great if there were an additional button "Add field" and a place to write "Formula", which we could use to add additional parameters to the Email that we send. Please see the picture attached.
    Attached Files
  • lazovic
    Super Moderator
    • Jan 2022
    • 1208

    #2
    Hi Laimonas,

    As a temporary solution, I can suggest you to use Execute Formula Script using this formula:
    Code:
    $emailId = record\create(
             'Email',
             'to', $recipientEmail,
             'status', 'Draft',
             'parentId', entity\attribute('id'),
             'parentType', entity\attribute('type')
    );
    
    ext\email\applyTemplate($emailId, 'some-email-template-id');
    ext\email\send($emailId);
    The value of the $recipientEmail variable can also be easily pulled out using formulas. I can help you in this matter if you wish.

    Comment


    • yuri
      yuri commented
      Editing a comment
      I wouldn't call it a temporary solution. It's a good solution.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9636

    #3
    It's already possible to update an email record with Task > Update Created Record. The email entity will be available in the list. Place the task flow element after the Send Message element in the process flow.

    Plus it's possible to use process variables in the email template (see docs).
    Last edited by yuri; 07-14-2022, 03:55 PM.

    Comment

    • SailReal
      Junior Member
      • Jun 2025
      • 12

      #4
      Originally posted by lazovic
      Hi Laimonas,

      As a temporary solution, I can suggest you to use Execute Formula Script using this formula:
      Code:
      $emailId = record\create(
      'Email',
      'to', $recipientEmail,
      'status', 'Draft',
      'parentId', entity\attribute('id'),
      'parentType', entity\attribute('type')
      );
      
      ext\email\applyTemplate($emailId, 'some-email-template-id');
      ext\email\send($emailId);
      The value of the $recipientEmail variable can also be easily pulled out using formulas. I can help you in this matter if you wish.
      This works but unfortunately I can not enable here the `optOutLink` substitution from the template like with the `Send Message Task`. Is there another way to dynamically select the template but also have the `optOutLink` substitution?

      Comment


      • SailReal
        SailReal commented
        Editing a comment
        To clarify my situation: If I use `Send Message Task` and check the `Enable Output Link` option, it works as expected (optOutUrl or optOutLink is substituted via the template). Only when I use the `Script Task` mentioned in https://forum.espocrm.com/forum/feat...1586#post81586 to send the email optOutUrl or optOutLink is not substituted via the template. But I need to use the `Script Task` because in `Send Message Task` I can not dynamically adjust the used template.

        So it seems to be a "problem" with the `Script Task` create record VS `Send Message Task` and I'm trying to workaround this.

      • SailReal
        SailReal commented
        Editing a comment
        yuri I guess there is no option, right?

        Maybe some background to my use case: I have a Flowchart for an cold email outreach which has 5 email send stages, each stage has an email template with 2 variants (depending on the language of the lead).
        Last edited by SailReal; Today, 09:40 AM.

      • SailReal
        SailReal commented
        Editing a comment
        I tried to create just one template and add all the languages and stages, but this only works with record\create('Email'), because the process variables used in the template to set the correct content depending on the stage and lang aren't substituted (or better not usable in control flow like e.g. in ifEqual) in the `Send Message Task` but `Send Message Task` is needed for the opt out handling. So, I think I'm pretty stuck here.
        Last edited by SailReal; Today, 01:30 PM.
    Working...