How to use capabilities property of TidIMAP4?

162 views Asked by At

I wanted to find out if anyone knows how to use the capabilities property of the Indy class TIdIMAP4? Its documentation appears to be the minimal auto-generated documentation that does not describe it's purpose or usage at all.

So I wrote some code like so (connection is already open at this poing)

if IMAP.Capabilities.IndexOf('MOVE')<>-1 then begin
  IMAP.SendCmd(...);
end;

However, when this didn't seem to be working, I started investigating and found IMAP.Capabilities was an empty string list. I know capabilities are sent by the server on connect, without requesting them, but they appear not to be automatically populated? Am I wrong in thinking that the capabilities list should have been filled in simply by connecting?

Or is there some other command I have to call first? The Capability command looks promising, except that that method appears to store the results in a user-provided string list, so I'm slightly skeptical the string list in IMAP.Capabilities will be magically filled in from this (and if that were the case, why do I have to provide an empty list?) Edit: It appears Capability is overloaded and there's a no-arg version of it. However, I'm still seeing a blank capability list after calling that.

1

There are 1 answers

0
Jessica Brown On

I decided to play with the other overloaded version of Capability where you provide a stringlist to the capability function. This did not return an empty list. I'm suspicious the other method was not working due to some type of variable scope issue, so this is really only a partial answer.

Using Capability in this manner did work:

var
  capas : TStrings;
begin
  capas := TStringList.Create;
  IMAP.Capability(capas);
  if (capas.IndexOf('UIDPLUS')<>-1) then
    IMAP.SendCmd('UID EXPUNGE '+uidList.commaText);
  capas.free;
end;