Sending Statement PDF through email

Requirement

We need to render statement and send the statement pdf as email attachment

Solution

Add the following code snippet in your script for to render statement as pdf and send as attachment through email

//Code for rendering the statement

               var transactionFile = render.statement({
                    entityId: customerId,//Provide customer id for the statement
                    printMode: render.PrintMode.PDF,
                    startDate: '22/02/2022',  //Provide start date
                    statementDate: '22/02/2022'  //Provide statement date
                });

//Send the statement as email attachment


                 email.send({
                       author: 5334,
                       recipients: customeremail, //Provide recipient email
                       cc: ccEmail,   //Provide email for CC
                       subject: 'Statement test Subject', //Subject of email
                       body: 'Statement Test body', //Body of email
                       attachments: [transactionFile],    //Attaching statement pdf
                    
      
                       });

Leave a comment

Your email address will not be published. Required fields are marked *