attache a file to an email via a workflow

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamie
    Senior Member
    • Aug 2025
    • 177

    #1

    attache a file to an email via a workflow

    i am trying to make a workflow to send out an e-invoice file, though i can't figure out your attachment format

    This seems to be what i want to use, though i was expecting a drop-down to select what variable to use as an attachment, and the description isn't too clear on how i can achieve this

    yuri or rabii any help or clues would be greatly appreciated



    Click image for larger version

Name:	image.png
Views:	0
Size:	8.8 KB
ID:	123432
  • rabii
    Active Community Member
    • Jun 2016
    • 1362

    #2
    hey jamie

    you can generate a pdf file and assign it to a variable that you can use in the attachment variable field.

    Before sending email task - add a formula task (you need to make sure that you pass the correct invoice id and template id to the formula function) see formula below

    PHP Code:
    $einvoiceId ext\pdf\generate(
        
    'Invoice'// the invoice entity
        
    id,    // the id of the invoice 
        
    '65d3303da061d8ef7'// id of the pdf template e.g https://demo.eu.espocrm.com/?l=en_GB#Template/view/65d3303da061d8ef7
        
    'e-invoice-Ref-101.pdf' // choose a name of the pdf file
    ); 

    then use the variable $einvoiceId in the attachments variable field as {$$einvoiceId}

    Please note that this will generate an invoice as for e-invoice i guess the function is missing the e-invoice format. i guess the team can advise how to apply that or maybe they will introduce a new formula for the sales pack.

    Hope this helps
    Rabii
    EspoCRM & Web Dev

    🔗 See what I’ve built for EspoCRM

    Comment

    • jamie
      Senior Member
      • Aug 2025
      • 177

      #3
      Originally posted by rabii
      hey jamie

      you can generate a pdf file and assign it to a variable that you can use in the attachment variable field.

      Before sending email task - add a formula task (you need to make sure that you pass the correct invoice id and template id to the formula function) see formula below

      PHP Code:
      $einvoiceId ext\pdf\generate(
      'Invoice'// the invoice entity
      id// the id of the invoice
      '65d3303da061d8ef7'// id of the pdf template e.g https://demo.eu.espocrm.com/?l=en_GB#Template/view/65d3303da061d8ef7
      'e-invoice-Ref-101.pdf' // choose a name of the pdf file
      ); 

      then use the variable $einvoiceId in the attachments variable field as {$$einvoiceId}

      Please note that this will generate an invoice as for e-invoice i guess the function is missing the e-invoice format. i guess the team can advise how to apply that or maybe they will introduce a new formula for the sales pack.

      Hope this helps
      ahh so this is a variable to be used by a flowchart? its in the workflow and i just want to make a simple work flow that attaches a file to an email

      yuri is there any way todo this?

      Comment


      • rabii
        rabii commented
        Editing a comment
        this works in workflow and flowchart no difference - it even works in entity formula.
    Working...