I have to parse the html of an email, get all the img tags and replace the src value with the url of the image I want.
This part is already done. I can access the <img> and change the attribute with the url I want.
The problem is that when I print the html the src equals cid:companylogo and it should be the full url of the image I gave.
I need to know how to load the html after the src values of the <img> in the original html are changed. The below code receives as a parameter the original html of the email in a string which is "body"
string SRC = "";
int indice = 0;
//Console.WriteLine(body);
HtmlDocument email = new HtmlDocument();
email.LoadHtml(body);
foreach (HtmlNode img in email.DocumentNode.SelectNodes("//img"))
{
SRC = img.GetAttributeValue("src", null);
for (int i = 0; i < contentIDS.Count; i++)
{
if (SRC.Equals(contentIDS[i]))
{
indice = i;
break;
}
}
img.SetAttributeValue("src", urls[indice].ToString());//change src value
Console.WriteLine("URL" + img.GetAttributeValue("src", null));//its printed how i want to
}
body = item.Body;//am stuck here i want body to have a final value of the whole html but with the changes made in src above.
return body;
itemvariable you are referring to in the line before the return? - Odeditemat all, butemail. Why use the object you have not changed? - Oded