Send outlook Activity error

Hi All,

i am sending an email by reading config file value, till subject it is working fine but in body it is throwing error.
image
Note - there is no attach files here.

error - Log Message: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

Hi Rakesh,

Make sure you are not misssing any value while formating value.

String.format(“{0}”, provide an argument for this value.)

Cheers!


@jose.ordonez1 can you tell what is wrong in this.

input file value -
image

Hi @Rakesh_Tiwari

In the attachments arguments, try the below one,

String.format({0})

You’re not using String.Format correctly.

String.Format(“Some text {0} then some more text {1} then even more text {2}”,“Some Value”,“Another Value”,“Yet Another”)

This will result in: Some text Some Value then some more text Another Value then even more text Yet Another.

The numbers in brackets are the indexes of the rest of the arguments. The number in brackets gets replaced with the values in the rest of the arguments.

Hi Rakesh,
Attached below you can find a demo .xaml file with the solution.
Main.xaml (10.8 KB)

Cheers!

file is not opening, it’s says file is not valid

@jose.ordonez1

where this expression should be used in body of email?

Hi Rakesh,
Try this one.

String.Format("Hi,<br />
<br />
The RPA process encountered an Error When trying To login To {0}. Please validate If the webpage Is working .<br />
<br />
<br />
Bot Name: {1} <br />
<br />
Actions To be taken: Please run the bot again once the web page Is working properlly. 
<br />
<br />
Thank you", "Google", "BotDemo")

Demo.zip (3.0 KB)

it has a package issue, can share in a screenshot?

image

Hi Rakesh_Tiwari,
Please check the image below:

  • This is the code demo assigned to the str_emailBody.
String.Format("Hi,<br />
<br />
The RPA process encountered an Error When trying To login To {0}. Please validate If the webpage Is working .<br />
<br />
<br />
Bot Name: {1} <br />
<br />
Actions To be taken: Please run the bot again once the web page Is working properlly. 
<br />
<br />
Thank you", "Google", "BotDemo")

still, throwing same error.

just one doubt no need to assign any argument right?

You use that expression anywhere you have a string where you want to replace certain values.

You do not need arguments. String.Format just returns a string. You can use it anywhere you’d use a string. Body, subject, Assign activity, literally anywhere you can use a string (value or variable) you can use the String.Format expression. Expressions return values of certain types, they’re no different from literals or variables.

not sure, why it is still throwing error then.

Because you aren’t providing the values to replace with.

String.Format(“some text {0} some test”) will throw an exception because you didn’t tell it the value to replace {0} with. You have to do String.Format(“some text {0} some text”,“Replace with this text”) and you’ll get back “some text Replace with this text some text” as a string value.

Put the dependencies back how you had them. Your problem is not caused by dependency version, it’s just an incorrectly written String.Format statement.

my question is why should i provide value here, when i reading everything from config file.

String.Format is used to replace values into a string. If you don’t need to replace values into a string, then you don’t need to use String.Format. Just use Config(“Value Name”).ToString which is an expression that outputs that config value as a string.