INDY9 - DNSResolver SAMPLE

Hi all;

I was searching for whole days how to use Indy9 DNSResolver, finding only
people like me, but not sample codes. I was lucky to write a litlle code
that works, so I am sharing it here. I use it for mail purposes, so I use
qtMX.

function TfrmMain.GetMailHosts(const sDominio: string; MailHosts:
TStringList): Boolean;
var
  s: string;
  i: integer;
begin
  Msg('Resolviendo DNS');
  MailHosts.Clear;
  if sDominio = '' then Exit;
  DNS.QueryResult.Clear;
  try
    DNS.Active := True;
    DNS.QueryRecords := [qtMX];
    DNS.Resolve(sDominio);
    for i := 0 to (DNS.QueryResult.Count - 1) do
    begin
      s := DNS.QueryResult.Items[i].Name;
      if (s <> sDominio) and (MailHosts.IndexOf(s) < 0) then
        MailHosts.Add(s);
    end;
  except
    On Exception do MailHosts.Clear;
  end;
  DNS.Active := False;
end;

Best regards,
Daniel Schaer