IMAP搜索命令的替代方法 [英] Alternative for IMAP search command

查看:153
本文介绍了IMAP搜索命令的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要IMAP搜索命令"未隐藏的搜索1:* 1:*未删除"的替代方法,因为电子邮件服务器禁止了搜索命令.我尝试使用"状态(未显示)",但是尽管有未读消息,但它始终返回零.该命令是否还有其他选择?预先感谢.

I need an alternative for IMAP search command "A search 1:* unseen not deleted" since the email server is forbidding the search command. I tried using "A status (unseen)" but it always returns zero though there's an unread message. Is there any alternative for the command? Thanks in advance.

推荐答案

您的问题是IMAP服务器完全不支持SEARCH还是不喜欢您的特定SEARCH命令?如果是后者,我们可以简化:

Is your problem that the IMAP server doesn't support SEARCH at all, or that it doesn't like your particular SEARCH command? If it's the latter, we can simplify:

A SEARCH UNSEEN UNDELETED

(因为1:*是隐式的).甚至更简单-以防万一服务器完全不喜欢和-c一起使用-c会是:

(as 1:* is implicit). Even simpler -- just in case the server doesn't like and-ing SEARCH terms together at all -- would be:

A SEARCH UNSEEN
B SEARCH DELETED

,并在逻辑上执行代码中的AND.

and logically doing the AND in your code.

这样做的蛮力方式是:

C UID FETCH 1:* FLAGS

,然后选择既不包含\Seen也不包含\Deleted的所有内容. (我建议使用UID FETCH,因为类似的FETCH命令将在空文件夹中返回BAD.)

and then picking out all the ones with neither \Seen nor \Deleted. (I'm suggesting UID FETCH because a similar FETCH command will return BAD on an empty folder.)

此外,您不应在当前选择的文件夹:

注意:STATUS命令用于访问 当前所选邮箱以外的邮箱状态 邮箱.因为STATUS命令会导致 邮箱要在内部打开,因为 信息可通过其他方式在所选对象上使用 邮箱,不得在STATUS命令上使用 当前选择的邮箱.

Note: The STATUS command is intended to access the status of mailboxes other than the currently selected mailbox. Because the STATUS command can cause the mailbox to be opened internally, and because this information is available by other means on the selected mailbox, the STATUS command SHOULD NOT be used on the currently selected mailbox.

这篇关于IMAP搜索命令的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆