Using String.Format to send mails does not work inside a For Each Row activity

Hello everyone,

has anyone encountered this before?

I have an excel file with some rows in it. I need to send an email for each row, sounds like a simple thing, actually.

I am using For Each row activity for this and this works for the TO and Subject fields (Send SMTP activity)

Since I have a customized text for the body (html) and parameterizing some entries, I decided to use String.Format(str_EmailBody, row(“display name”), row(“username”), row(“request id”))

somehow using this does not work for the body, it doesn’t move to the next row and keep on using the same information in the 1st row.

Any solution anyone can share is highly appreciated! :smiley:

Hi @Twits_Rombaoa,
Can you show your workflow example?

something like this…
image


Hmmm indeed it’s strange. Try maybe experiment with using row(index) instead of row(column name). Eventually you can try row.item(index) as well.

thanks, i tried those but no luck

1 Like

You could for the test build similar table using Create Table activity. And write to it couple of rows from excel. Then based on this table in debugging process you will see which values are taken. Maybe this will help somehow.

Fine
may i know what is assigned to str_EmailBody variable
if possible can i have a screenshot of it
we need to have three place holders like this {0} {1} {2} only then the values i.e., the arguments we have passed like row(“display name”), row(“username”), row(“request id”) will be placed in that place holder

Cheers @Twits_Rombaoa

hi @Palaniyappan, was hoping to get your attention as i saw some of your posts related to this one. :smiley:
this is what i have for str_EmailBody:

1 Like

This one looks good
but i have a small query like are we trying to send this text as HTML
if not kindly remove the html tags and try once if possible
Cheers @Twits_Rombaoa

yes, the email must be in html, but for testing purposes i unchecked isBodyHTML properties, unfortunately, it’s still the same, the To and Subject is working fine but body for all emails contains only the 1st record.

i think this is a bug already :slight_smile: wondering if UIPath is even aware of this hehe

1 Like

did we try on removing the tags and send that simply as a text
Cheers @Twits_Rombaoa

yup my text file contains only the following:

{0}
{1}
{2}
{3}

i wonder why it didnt work
the values will surely be placed in the respective place holders mentioned in string.format method
hmmm. strange
Cheers @Twits_Rombaoa

the values were placed in the right order, that is correct, but the thing is it doesn’t move to the next row to fetch the next set of values, just keep on using the values of the 1st row.

can i have a screenshot of it if possible
Cheers @Twits_Rombaoa

OMG! i just fixed it hahaha

instead of using Assigned Activity, just do the String.Format right in the Body field of the SMTP!

:smiley: :smiley:

2 Likes

yah remove the assign activity of str_emailbody and mention that directly in the BODY property of the send mail activity
Cheers @Twits_Rombaoa

haha, that is still really strange, why Assign activity doesn’t work :wink:

this gave me the headache the whole day!!! :smiley:

@Twits_Rombaoa

Yes String_Emailbody is replaced… you have set one Constant Temp Variable…

1 Like

but the Assign activity is also inside the For Each Row, so it is supposed to be overwritten by the value of the next row