I fixed it with this, but I'm still curious why it didn't worked the "normal" way.
MailBody = new StringBuilder(Mail.Body);
MailBody.Replace("cid:header", "header.jpg");
Mail.Body = MailBody.ToString();
Question
So, I just came across a minor problem, given a mail object:
Mail = new MailMessage();
Generating it's body:
Mail.IsBodyHtml = true;
Mail.Body = GenerateHTMLFoo(); // it's a stringbuilder
Now Mail.Body contains a whole HTML document, just showing the first line for example:
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
Then I send the mail, and after that I would like to replace something in it's body:
Mail.Body.Replace("cid:header", "header.jpg"); // no effect
Any ideas? Mail.Body is a string, and the replacing has no effect on it.
La solution
I fixed it with this, but I'm still curious why it didn't worked the "normal" way.
MailBody = new StringBuilder(Mail.Body);
MailBody.Replace("cid:header", "header.jpg");
Mail.Body = MailBody.ToString();