Is it possible to detect which parts of the email message are signature and previous messages quoted to this message for excluding those parts, using the MimeKit?
Asked
Active
Viewed 167 times
1 Answers
1
You can do something like this:
static string ExcludeQuotedTextAndSignature (string bodyText)
{
using (var writer = new StringWriter ()) {
using (var reader = new StringReader (bodyText)) {
string line;
while ((line = reader.ReadLine ()) != null) {
if (line.Length > 0 && line[0] == '>') {
// This line is a quoted line, ignore it.
continue;
}
if (line.Equals ("-- ", StringComparison.Ordinal)) {
// This is the start of the signature
break;
}
writer.WriteLine (line);
}
}
return writer.ToString ();
}
}

jstedfast
- 35,744
- 5
- 97
- 110
-
Is it possible to do the same with the HTML part of the body too? – Rojan Gh. Jun 18 '20 at 02:55
-
1HTML gets infinitely more interesting. Good luck is all I’ve got to say. – jstedfast Jun 18 '20 at 02:56
-
Dang! Thanks for the tip anyway! :) – Rojan Gh. Jun 21 '20 at 12:54
-
@RojanGh. Did you figure out how to do this for HTML part of body? – WhatsUp Jun 01 '23 at 16:54