I am having html code in string variable. In that I have mutiple image tags and I want replace the src of image tag with new src.
I am using this code :
foreach (MessagePart attchment in unseenMessage.FindAllAttachments())
{
attchments = Guid.NewGuid().ToString() + attchment.FileName;
string src="cid:"+ attchment.ContentId;
string newsrc = "/Attachment/" + attchments;
emailbody.Replace(src, newsrc);
string filepath = "D:\\AceoCRM\\Aceo.Web\\Attachment\\" + attchments;
using (FileStream fs = new FileStream(filepath, FileMode.CreateNew))
{
fs.Write(attchment.Body, 0, attchment.Body.Length);
fs.Close();
}
listOfAttachments.Add(attchments);
}
Replacedoesn't change the string, it returns an updated string instead. So you need to assign it back toemailbody.