String parsing isn't so much about the unknown string; it's about the known string
You didn't post what your html email looks like but let us suppose it looks like this:
<p>Name and Surname: user will enter value</p>
<p>Rate: user will enter value</p>
As you can see it's quite a uniform structure. We could split on "<p>"
and "</p>"
:
string parts = body.Split(new []{ "<p>", "</p>"}, StringSplitOptions.RemoveEmptyEntries);
And then we could loop through the resulting array looking for what we do know so we can retrieve what we don't know:
foreach(string part in parts)
{
if(part.StartsWith("Name and Surname:"))
name = part.Substring("Name and Surname:".Length).Trim();
else if ....
}
Parsing this way isn't the most robust solution, but even robust solutions can be broken by relatively minor changes in the process. You could use HtmlAgilityPack to parse the HTML, look in every child element of the form for your known strings, change things so that it is looking for all three words "name" "and" "surname" individually and only deciding it's a name if all 3 are present .. and then someone will tweak it to say "firstname and lastname" and it breaks anyway. You have to decide how much effort to put into making a good job of a bad situation, and my advice would be "not much; do the minimum necessary while you set about replacing it with something proper, and increase the priority of this becomes a consistent pain point"
Really the entire system needs to be better engineered, web service, api calls etc but if this is what you're stuck with, and it's software preparing the email things will only really break if the remote software changes