IMAP.SendCmd(ImapCmdNum(),'UID STORE '+uidList.CommaText+' -X-GM-LABELS ("'+ labelname + '")', true) Īnd here’s the helper functions, minus the global/class/whatever variables: If HasCapa('X-GM-EXT-1') and (uidList.Count >0) and (labelname '') then begin Remove label is basically the same thing but with a minus sign: function RemoveGmailLabelFromMsgs(const uidList: TStrings labelname : string): boolean I also have some commented out exception handling that was helpful to debugging when my SendCmd wasn’t formatted correctly, but is neither needed nor useful for production code. Third parameter is what responses to look for to know this command is “complete”, and the fourth is whether to look for a single line response or multi-line response. Second is the remainder of the actual command. The first parameter is a sequence number so that the response can be matched up with the command. It was a little tricky figuring out how to use this function since documentation and examples are a little scarce. Dialogs.ShowMessage('Exception message = '+E.Message) Īt the heart of it, I am using Indy’s SendCmd function to manually send the command. Dialogs.ShowMessage('Exception class name = '+E.ClassName) IMAP.SendCmd(ImapCmdNum(),'UID STORE '+uidList.CommaText+' +X-GM-LABELS ("'+ labelname + '")', true) If HasCapa('X-GM-EXT-1') and (uidList.Count > 0) and (labelname '') then begin So I thought I’d share that code: function AddGmailLabelToMsgs(const uidList: TStrings labelname : string) : boolean I’m still working on figuring out how to fetch and read the fetched labels, but by using the SendCmd function to manually send the IMAP commands I got adding and removing labels working.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |