如何使用 MimeKit 从电子邮件消息中排除签名和引用部分?

How to exclude the signature and quoted parts from email message using MimeKit?

是否可以使用 MimeKit 检测电子邮件的哪些部分是签名以及引用此邮件的先前邮件以排除这些部分?

你可以这样做:

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 ();
    }
}