Insert Text into a body and Re-enter

Hi Guys,

I have a body of text in form of a string, but I want to now assign to include a name after the work “Hi,” but to also include the comma after the name now.

Could you help me form the code - I currently have an assign activity with the following:

New_Str = email_Text.Replace(“Hi,”,“Hi “+in_FullName.Substring(” “,(0))+”,”

So I want to set the new string to include the Name, but only the first name - As ‘in_FullName’ contains First and Last name.

Could you please help me form the above, as the code above returns errors.

Many Thanks!

1 Like

your variable in_FullName = kyle brow
you want it like Hi, kyle Brown
@Kyleb91

1 Like

image

"Hi, " +in_FullName like this
@Kyleb91

1 Like

Hi Yes, so I want the substring so just “Kyle” and then add this to the email string after “Hi” but before the comma - The first line of the email text is “Hi,”

So I want the new text to read “Hi Kyle,” and then use the rest of the string.

1 Like

Hey,

so tell me this what does your in_FullName variable has?
@Kyleb91

in_FullName is “Kyle Brown”

1 Like

so from that you want First Name??

Yes,

I was trying to combine all in the one assign activity:

New_Str = email_Text.Replace(“Hi,”,“Hi “+in_FullName.Substring(” “,(0))+”,”

1 Like

FirstName =in_FullName.Split({" "},stringSplitOptions.RemoveEmptyEntries)(0) this will give you Kyle

you can do this "Hi " +FirstName+ “,”

@Kyleb91
i hope this helps you, let me know
cheers
Happy Learning.

1 Like

Thanks man - so would

Newstr = email_Text.Replace(“Hi,”,“Hi “+in_FullName.Split({” “},stringSplitOptions.RemoveEmptyEntries)(0)+”,”)

Still return the rest of the email after the Hi Kyle,?

1 Like

what does your email_text contains?

a body of text - so:

"Hi,

This is a email text which follows the hi etc…

Many Thanks"

It does re the above thanks!

Is there a way of keeping the original formatting of the email, as I am now left with a block of Text, not in email format.