Office 365 send mail - How do I insert strings into the body?

With the old outlook “send mail” I had a text file template which the bot would use and it had points in the template where it would fill in the text based on variable strings. e.g a specific username would be sent to each recipient based on the values held in a csv file.

Now that the new office365 send mail activity does not use a template, it lets me put the text in the activity directly in quotes. Unfortunately I cannot see a way to now easily add the variables into the body of the text again. Is there a simple way to do this?

Hi @Zephyr,

Determine the places to change in the template and add labels.

For example ;

Hi [Name],

Then you can replace all these label fields with the variable you want with the replace function.

resultString.Replace(“[Name]”,“name”)

or

if you are in a loop.
resultString.Replace(“[Name]”,row(“Name”).ToString)

I hope that will be useful.

Regards,
MY

you can try with html template it will be easy approach

@Zephyr Try below steps

  • Let say your template is something like below
<html>
<body>
<p> Hello Friend </p>
</body>
</html>
  • Save the template in a text file
  • Read the template using Read Text File activity, output is string (Str)
  • Use office 365 send mail activity, within the body pass the below exp
Str.Replace("Friend", "UiPath")
  • if you want to replace the multiple values then follow the below syntax
Str.Replace("Data you want to replace", "Replace value").Replace("Data you want to replace", "Replace value")....
  • Str is the output of Read Text File activity
  • You can also pass the string variables to replace a value if required

Thanks I managed to get it working with this approach. Now my only issue is it doesn’t recognise my shared inbox, its saying ErrorAccessDenied. I did have to log in to a pop up browser window, so I’m not sure if further settings are needed to allow it to see my shared inboxes

@Zephyr You have to work with your IT team to get access to shared mail box

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