Text Outlook Mail in Config and put variables inside

Hi! :grinning:

I have the e-mail body/subject content in config file (not in HTML format).

I would also like to put there information about the start or end time of the robot.
These values are assigned during the process.

Is there any other way to add value to the body/subject text (in this situation) than using the replace function? :upside_down_face:

Best wishes,
F.

Hi @Franciszek_Milczarsk

Yes… You can do that… Refer to my answers to the below thread which I used the String.Format option…
It will help you get your task done.

I always prefer to keep the body of the mail in Database as a string. Dont keep it in config instead you can keep it as a separate text file.

And coming to your question. Pre-format the text with dummy variables and replace it with the variables before sending mail.

For instance:

body.txt

Start Time: vStartTime
No of Records Processed: vNoOfRecordsProcessed
End Time: vEndTime

Read the text file and store it as strBody

Then Replace the actual variables like the following.

strBody = strBody.Replace("vStartTime", strStartTime).Replace("vNoOfRecordsProcessed", strNoOfRecordsProcessed).Replace("vEndTime", strEndTime)

Then use the variable in mail

Hope it helps… :grinning:

1 Like

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