Manipulate Rebex.MailMessage Html String -



Manipulate Rebex.MailMessage Html String -

i working on message watcher service have , task embed message details message body.

i have tried using string builder have found message body html based string.

i'm wanting know if there way can add together values want add together @ point in html string?

below section of html string want manipulate. text needs inserted straight after body tag.

<body lang=en-gb link=blue vlink=purple> <div class=wordsection1> <p class=msonormal> <span style='font-size:10.0pt;font-family:"century gothic","sans-serif";color:black'>another test appendline();<o:p></o:p> </span> </p>

here how trying it:

stringbuilder sb = new stringbuilder(); sb.append("from: "); sb.append(message.from.tostring()); sb.appendline(); sb.append("sent: "); sb.append(message.date.tostring()); sb.appendline(); sb.append("to: "); sb.append(message.to.tostring()); sb.appendline(); sb.append("subject: "); sb.append(message.subject); sb.appendline(); sb.append(message.bodyhtml);

unfortunately printed from, sent, to, subject values onto 1 line , output html section.

if more info needed please allow me know , provide it.

instead of appending body html, seek regex replace:

stringbuilder sb = new stringbuilder(); sb.append("from: "); sb.append(message.from.tostring()); ... sb.append("subject: "); sb.append(message.subject); sb.appendline(); // not guaranteed work arbitrary html strings regex regex = new regex(@"(<body[^>]*>)", regexoptions.ignorecase); message.bodyhtml = regex.replace(message.bodyhtml, "$1\r\n" + sb.tostring());

disclaimer: please advised processing html regular expressions generally regarded bad idea. although code above might work in 98% of cases, regular expressions not task of parsing arbitrary html. html sophisticated regex. if need process arbitrary html bodies (not 1 above), recommend using proper html parser such html agility pack - seemingly-simple operations such inserting text after body tag.

string mailmessage

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -