1

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?

Rojan Gh.
  • 1,062
  • 1
  • 9
  • 32

1 Answers1

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