使用 Indy 检索 Gmail 标签?

Retrieve Gmail Labels with Indy?

根据 this thread(以及源代码中的各种提示,如变量名),Indy 支持获取 gmail 标签,但不支持设置或删除它们。但是,到目前为止,此功能似乎尚未记录。谁能帮我填写有关如何使用 Imap 检索 Gmail 标签的详细信息?

我应该调用哪个函数来检索标签并让 Indy 为我解析结果?虽然我当然可以手动调用 SendCmd() 来请求标签 ('C2 UID FETCH 92 (X-GM-LABELS)') 类似于我手动 setting/removing 标签的方式(Indy 还没有这样做),但解析 FETCH 结果是我需要做的事情know 已经内置到 Indy 中,所以我不想在这里重新发明轮子来解码 FETCH 结果。现在,为了简单起见,假设我 只是 想要标签而不是其他 envelopes/headers/message 部分。

似乎确实有很多功能可能(或可能不相关)相关,但有太多可供选择的功能,而且其中很多只有自动生成的文档,找出要尝试的功能, which 属性 (or sub-属性) or function 来找到实际的标签有点让人望而生畏。谁能在这里指出正确的方向?

Indy supports fetching gmail labels but not setting or removing them.

不完全是。 TIdIMAP4 支持按 Gmail 标签搜索电子邮件,但尚不支持检索特定电子邮件的 Gmail 标签。

However, as of yet, this functionality appears to be undocumented.

Indy 在过去几年中添加的许多功能仍未记录在案。

Can anyone help me with filling in the details about how to retrieve Gmail labels with Imap?

Some GMail IMAP extensions added to TIdIMAP4

The TIdIMAP4SearchKey enum has been updated with new items to support the X-GM-RAW, X-GM-MSGID, X-GM-THRID, and X-GM-LABELS extensions in SEARCH commands issued by the SearchMailBox() and UIDSearchMailBox() methods.

The TIdIMAP4FetchDataItem enum has been updated with new items to support the X-GM-MSGID, X-GM-THRID, and X-GM-LABELS extensions in the FETCH command, however no TIdIMAP methods currently use these new items yet.

Support for the X-GM-LABELS extension in the STORE command has not been implemented yet.

Which function(s) should I call to retrieve the labels and have Indy parse out the results for me?

目前支持 GMail 标签的方法只有 TIdIMAP4.SearchMailBox()TIdIMAP4.UIDSearchMailBox()

Although I could certainly manually call SendCmd() to request the labels ('C2 UID FETCH 92 (X-GM-LABELS)') similar to how I'm manually setting/removing labels (which Indy doesn't yet do), parsing FETCH results is something that I know is already built into Indy, so I don't want to re-invent the wheel here to decode the FETCH results.

抱歉,您必须这样做。尽管 TIdIMAP4 会解析 FETCH 响应中的标志,但它会丢弃 TIdMessageFlagsSet 不支持的任何标志(已回答、已标记、已删除、草稿、已查看、最近)。因此,虽然可以自动解析 Gmail 标签,但 TIdIMAP4 还没有地方可以保存它们。

Can anyone point me in the right direction here?

这时候就得手动实现了