Monday 15 February 2021

How to download Base64 pdf file by using Pega Activity

Hi Friends, In this post we will see how to download a file which is in base 64 encoded format.


URL to get encoded format of a file : https://base64.guru/converter/encode/file


Selected a pdf file from my local system and click encode file to base 64 button to get encoded data of the file.

Created a sample activity VerifyWork, in that called an pega activity named View of Code-Pega-PDF class.






This activity use is to download the base 64 format pdf file .

For this activity we have to provide 2 parameters,

PDFName - in which name the pdf file should download
PDFDocument- base 64 format of pdf file.

Added Java step to decode base 64 into byte array.



Java code:

String S = tools.getParamValue("PDFDocument").toString();
byte[] byteArray =  new com.pega.pegarules.pub.util.Base64Util().decodeToByteArray(S);
tools.putParamValue("PDFDocument",byteArray);

Lets run the activity and verify our work.



We can see the pdf file is downloaded on running the verifywork activity. 

Hope this topic understandable to everyone. Comment if you have any doubts.

How to send correspondence in Pega

 Hi Friends, today we will see how to send correspondence in Pega.


Steps involved:

    Create a new email account(gmail)

    Make email as low security

    Configure email account rule

    Configure steps to send correspondence


Step1: Create a new email account

I am creating a new gmail account for test. 


Created new email account




Step 2: Make email as low security

Go to google account-> security -> Less Security app access -> Switch on.


Now my email account is less secure.



Step 3: Configure email account rule


Create a new email account rule

Rule Explorer -> Integration Resources -> Email account -> Create



In the email account rule, selected account provider as Google email, why means we have created that Gmail account for sending correspondence from Pega.

In Email address, UserID and Reply to provided the email id.

In Display Name, provide any name.

In Password, provide the gmail account password.




Use test connectivity to check whether email account configured without any issue or not.

In our case, overall result is good.

Step 4: steps to send correspondence


Save as getEmailSenderInfo activity into our ruleset version


In first step, For pxAccountName provide our email account value, so that Pega will select our email account to send correspondence. 


Save and keep this rule in checkout.


Created a sample activity(VerifyWork) to test our work, in this activity called an Pega activity named SendSimpleEmail.

For SendSimpleEmail activity we have to provide necessary parameter to send correspondence
    I have provided

        To - in this parameter we have to provide to address to which we want to send email
        Subject- Here we have to provide the subject for the email
        In CorrName - Provide the correspondence template which we want to send as body for email.

Save the rule.

Sample correspondence rule created for test.



Lets run the activity and check whether email is sending or not.


Activity ran successfully.


Email received to the To address

Email content:



Hope everyone understand this concept , if any doubts ask in comment. thanks.