Retrieve Gmail Labels with Indy?

♀尐吖头ヾ 提交于 2019-12-11 09:44:32

问题


According to this thread (and various hints in the source code like variable names) Indy supports fetching gmail labels but not setting or removing them. However, as of yet, this functionality appears to be undocumented. Can anyone help me with filling in the details about how to retrieve Gmail labels with Imap?

Which function(s) should I call to retrieve the labels and have Indy parse out the results for me? 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. For now, to keep things simple, presume I just want the labels and not other envelopes/headers/message parts.

There do appear to be quite a few functions that might (or might not) be relevant, but with so many to choose from, and so many of them only having auto-generated documentation, figuring out which one to try, and which property (or sub-property) or function to find the actual labels is a little daunting. Can anyone point me in the right direction here?


回答1:


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

Not quite. TIdIMAP4 supports searching for emails by Gmail label, but does not yet support retrieving Gmail labels for specific emails.

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

A lot of functionality added to Indy in the past several years is still undocumented.

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?

The only methods that support GMail labels at this time are TIdIMAP4.SearchMailBox() and 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.

Sorry, but you will have to. Although TIdIMAP4 does parse flags in FETCH responses, it discards any flag that is not supported by TIdMessageFlagsSet (Answered, Flagged, Deleted, Draft, Seen, Recent). So while Gmail labels can be parsed automatically, TIdIMAP4 has nowhere to save them yet.

Can anyone point me in the right direction here?

At this time, you have to implement it manually.



来源:https://stackoverflow.com/questions/31420583/retrieve-gmail-labels-with-indy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!