Passing a variable into an email body from a "Read Text File" Activity

Hi all,
I’m hoping you can assist me with having a variable recognized and populate correctly in an email body.

I have the email body for my automation in a text file that is downloaded from a storage bucket location and then stored in a variable. The email body requires the values for certain variables to be populated within it and to do this i have put the variable name in the text file. When i run the automation the email comes through correctly, however the variable is not populated, with the variable name being there instead. Can you advise how i am able to have variables recognised within the text file and populate correctly in the email output?




Can you try the following step?

First, set {0} and {1} which you want to replace variable in text file as the following

The weekly Payment Proposal Run has been completed for Company Code {0} with the proposal having a total value of {1}

Next read it using ReadTextFile activity and get content. Let’s say strBody

Then use String.Format as the following

String.Format(strBody,{in_CompanyCode,in_CopyCodeTotal.ToString}) (2.5 KB)


1 Like


Another appoch would be to use replace function

is good for - this is the sentence

Now use str.Replace("<CODE>","day").Replace("<WHOM>","you")

Output - day is good for you


1 Like

Thanks @Yoichi, this fixed it.

I’ll definitely be using this method in the future :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.