procedure TCarrier.GetPOP3(POP3Obj:TIdPOP3); var itmp,ival:integer; Msg:TIdMessage; begin Msg:=TIdMessage.Create(self); try if not POP3Obj.Connected then POP3Obj.Connect; try for itmp:=1 to POP3Obj.CheckMessages do begin Msg.Clear; try POP3Obj.RetrieveHeader(itmp,Msg); if POP3Obj.SocksInfo.Password<>'' then if trim(msg.Subject)<>POP3Obj.SocksInfo.Password then continue; POP3Obj.Retrieve(itmp,Msg); for ival := 0 to Msg.MessageParts.Count-1 do if Msg.MessageParts.Items[ival] is TIdText then break; DataArrive(TIdText(Msg.MessageParts.Items[ival]).Body.Text,POP3Obj.Tag); POP3Obj.Delete(itmp); except continue; end; end; except end; POP3Obj.Disconnect; except POP3Obj.Disconnect; end; msg.Free; end; 这是我做的一个Lidy的例子,是根据邮件的标题来过滤的(用POP3Obj.SocksInfo.Password放置了邮件标题),如果被过滤的邮件标题和我定义的一致才收取邮件内容,否则只是对邮件头接收
var itmp,ival:integer;
Msg:TIdMessage;
begin
Msg:=TIdMessage.Create(self);
try
if not POP3Obj.Connected then POP3Obj.Connect;
try
for itmp:=1 to POP3Obj.CheckMessages do
begin
Msg.Clear;
try
POP3Obj.RetrieveHeader(itmp,Msg);
if POP3Obj.SocksInfo.Password<>'' then if trim(msg.Subject)<>POP3Obj.SocksInfo.Password then continue;
POP3Obj.Retrieve(itmp,Msg);
for ival := 0 to Msg.MessageParts.Count-1 do if Msg.MessageParts.Items[ival] is TIdText then break;
DataArrive(TIdText(Msg.MessageParts.Items[ival]).Body.Text,POP3Obj.Tag);
POP3Obj.Delete(itmp);
except
continue;
end;
end;
except
end;
POP3Obj.Disconnect;
except
POP3Obj.Disconnect;
end;
msg.Free;
end;
这是我做的一个Lidy的例子,是根据邮件的标题来过滤的(用POP3Obj.SocksInfo.Password放置了邮件标题),如果被过滤的邮件标题和我定义的一致才收取邮件内容,否则只是对邮件头接收