Config File - Mail body

Hello, everyone,

I want to store the mail text of the SMTP activities in the config file. The texts contain variables and also values ​​from the config. How can I capture such mail texts in the config? How do I have to store the variables and the values ​​in the mail text in the config?

1 Like

Hi @Prisemuetchen,

I would use some keys to be replaced. So, your mail text in the config file would be something like this:

“Hello {{name_key}}, Hope you are doing well! Best regards, {{sender_key}}”

Then, you can use .Replace() to replace those keys by real values.

Example: Config("MailBody").Replace("{{name_key}}",Receiver).Replace("{{sender_key}}",Config("Sender"))

In this case, Receiver is a variable and Sender value was retrieved from your Config variable.

If this solves your problem, kindly mark this post as solution to close this topic.

If you need extra help and/or have any question, please let me know :slight_smile:

Thanks!

Hi

Hope the below steps that could help you solve this issue with the help of String.Format method

–First store this string template in a text file or a config file

Name: {0}

Email: {1}

Phone Number: {3}

where 0, 1, 2 are the place holders where we are going to mention the string that is to be placed in 0, 1, 2
–and use read text file activity and pass the file path of the text file and get the output with a variable of type string named out_text

–then in the body mention as String.Format(out_text,“Mani”,“mani@gmail.com”,“1234123515”)
and the actual syntax is
String.Format("{0} {1} {2} …", “value1”,“value2”,“value3”)
where {0}{1} are already in our output variable obtained from read text file activity and value1, value2 and value3 are passed as string between quotes if they are values or if we have those values in variables then we can mention the variable name alone without double quotes around them like this
String.Format("{0} {1} {2} …", variablename1,variablename2,variablename3)

Hope this would help you

Cheers @Prisemuetchen