【发布时间】:2015-01-15 02:51:35
【问题描述】:
我有条件地在电子邮件中添加了一个自定义标题
我想使用 IMAP/SearchQuery 只返回带有标题的邮件。
不是它的值,只有在头部存在时才返回真/假。
有可能吗?谢谢。
【问题讨论】:
标签: mailkit
我有条件地在电子邮件中添加了一个自定义标题
我想使用 IMAP/SearchQuery 只返回带有标题的邮件。
不是它的值,只有在头部存在时才返回真/假。
有可能吗?谢谢。
【问题讨论】:
标签: mailkit
根据 rfc3501(IMAP 规范):
HEADER <field-name> <string>
Messages that have a header with the specified field-name (as
defined in [RFC-2822]) and that contains the specified string
in the text of the header (what comes after the colon). If the
string to search is zero-length, this matches all messages that
have a header line with the specified field-name regardless of
the contents.
要在 MailKit 中进行此搜索,您需要执行以下操作:
var results = folder.Search (SearchQuery.Header ("X-Custom-Header", string.Empty));
编辑:
我刚刚在 MailKit 中发现了一个逻辑错误,它决定将空字符串作为 ATOM 发送,而不是像它应该的那样发送 QSTRING。我已经在git master 中修复了这个问题,但还没有发布。这个周末我可能会这样做。
【讨论】: