Monday, 15 August 2011

String.Replace not working on long html code. (Mail.Body) -



String.Replace not working on long html code. (Mail.Body) -

so, came across minor problem, given mail service object:

mail = new mailmessage();

generating it's body:

mail.isbodyhtml = true; mail.body = generatehtmlfoo(); // it's stringbuilder

now mail.body contains whole html document, showing first line example:

"<!doctype html public \"-//w3c//dtd html 4.01 transitional//en\" \"http://www.w3.org/tr/html4/loose.dtd\">

then send mail, , after replace in it's body:

mail.body.replace("cid:header", "header.jpg"); // no effect

any ideas? mail.body string, , replacing has no effect on it.

i fixed this, i'm still curious why didn't worked "normal" way.

mailbody = new stringbuilder(mail.body); mailbody.replace("cid:header", "header.jpg"); mail.body = mailbody.tostring();

html string text replace document-body

No comments:

Post a Comment