如何使用 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 ();
}
}

最新更新