我在IdPOP3的UserName和Password中输入错误信息,为什么还是可以顺利的Connected。难道Connect时不检测UserName和Password。
但在CheckMessages时居然返回的是字符串????????????????????????????
但在CheckMessages时居然返回的是字符串????????????????????????????
解决方案 »
- 这个有树形结构的表格控件是什么?
- Table 问题!
- 关于Ehlib控件中SaveDBGridEhToExportFile的使用
- 我要在销售表中添加一个销售id,类型为char(20),要求是前8位为当日日期即20061030,后四位为0001的递增数字,大家有什么好的解决方法
- 在一个表中选择到符合条件的记录后放到dbgrid中,然后供用户再从中挑选,最后存入另外一个表中,怎么做??
- about http1.1的持续连接?
- listview排序
- 问题简简单单,快来吧,分多着呢。
- 真难受!怎么会出现record changed by another user?
- ADOQuery有几种提交方式?
- 请问文件关联以后,双击文件自动打开程序,在程序中如何获得这个文件的路径,和如何判断我是通过关联文件打开这个程序的?
- 关于字符格式?
但CheckMessages必须要有UserName和Password登录POP3的服务器,CheckMessages其实是IdPOP3封装好的方法,它的最原此的代码中应该是返回错误码,例如220等等。
但CheckMessages必须要有UserName和Password登录POP3的服务器,CheckMessages其实是IdPOP3封装好的方法,它的最原此的代码中应该是返回错误码,例如220等等。
Classes, IdGlobal,
IdMessage, IdMessageClient;type
TIdPOP3 = class(TIdMessageClient)
protected
FPassword: string;
FUserId: string;
public
function RetrieveRaw(const MsgNum: Integer; const Dest: TStrings): boolean;
function CheckMessages: longint;
procedure Connect; override;
constructor Create(AOwner: TComponent); override;
function Delete(const MsgNum: Integer): Boolean;
procedure Disconnect; override;
procedure KeepAlive;
function Reset: Boolean;
function Retrieve(const MsgNum: Integer; AMsg: TIdMessage): Boolean;
function RetrieveHeader(const MsgNum: Integer; AMsg: TIdMessage): Boolean;
function RetrieveMsgSize(const MsgNum: Integer): Integer;
function RetrieveMailBoxSize: integer;
published
property Password: string read FPassword write FPassword;
property UserId: string read FUserId write FUserId;
property Port default IdPORT_POP3;
end;implementationuses
IdTCPConnection,
SysUtils;function TIdPOP3.CheckMessages: longint;
var
Value1, Value2: string;
begin
Result := 0;
SendCmd('STAT', wsOk); {Do not localize}
Value1 := CmdResult;
if Value1 <> '' then
begin
Value2 := Copy(Value1, 5, Length(Value1) - 5);
Result := StrToInt(Copy(Value2, 1, IndyPos(' ', Value2) - 1));
end;
end;procedure TIdPOP3.Connect;
begin
inherited
Connect;
try
GetResponse([wsOk]);
SendCmd('USER ' + UserId, wsOk); {Do not localize}
SendCmd('PASS ' + Password, wsOk); {Do not localize}
except
Disconnect;
raise;
end;
end;constructor TIdPOP3.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Port := IdPORT_POP3;
end;function TIdPOP3.Delete(const MsgNum: Integer): Boolean;
begin
SendCmd('DELE ' + IntToStr(MsgNum), wsOk); {Do not localize}
Result := ResultNo = wsOk;
end;procedure TIdPOP3.Disconnect;
begin
try
WriteLn('Quit'); {Do not localize}
finally
inherited;
end;
end;procedure TIdPOP3.KeepAlive;
begin
SendCmd('NOOP', wsOk); {Do not localize}
end;function TIdPOP3.Reset: Boolean;
begin
SendCmd('RSET', wsOK); {Do not localize}
Result := ResultNo = wsOK;
end;function TIdPOP3.RetrieveRaw(const MsgNum: Integer; const Dest: TStrings):
boolean;
begin
result := SendCmd('RETR ' + IntToStr(MsgNum)) = wsOk; {Do not localize}
if result then
begin
Capture(Dest);
result := true;
end;
end;function TIdPOP3.Retrieve(const MsgNum: Integer;
AMsg: TIdMessage): Boolean;
begin if SendCmd('RETR ' + IntToStr(MsgNum)) = wsOk then {Do not localize}
begin
ReceiveHeader(AMsg, '');
ReceiveBody(AMsg);
end;
Result := ResultNo = wsOk;
end;function TIdPOP3.RetrieveHeader(const MsgNum: Integer;
AMsg: TIdMessage): Boolean;
var
Dummy: string;
begin
try
SendCmd('TOP ' + IntToStr(MsgNum) + ' 0', wsOk); {Do not localize} ReceiveHeader(AMsg, '');
Dummy := ReadLn;
while Dummy = '' do
begin
Dummy := ReadLn;
end;
Result := Dummy = '.';
except
Result := False;
end;
end;function TIdPOP3.RetrieveMailBoxSize: integer;
var
CurrentLine: string;
begin
Result := 0;
try
SendCmd('LIST', wsOk); {Do not localize}
CurrentLine := ReadLn;
while (CurrentLine <> '.') and (CurrentLine <> '') do {Do not localize}
begin
CurrentLine := Copy(CurrentLine, IndyPos(' ', CurrentLine) + 1,
Length(CurrentLine) - IndyPos(' ', CurrentLine) + 1);
Result := Result + StrToIntDef(CurrentLine, 0);
CurrentLine := ReadLn;
end;
except
Result := -1;
end;
end;function TIdPOP3.RetrieveMsgSize(const MsgNum: Integer): Integer;
var
ReturnResult: string;
begin
try
SendCmd('LIST ' + IntToStr(MsgNum), wsOk); {Do not localize}
if CmdResult <> '' then
begin
ReturnResult := Copy(CmdResult, 5, Length(CmdResult) - 4);
Result := StrToIntDef(Copy(ReturnResult, IndyPos(' ', ReturnResult) + 1,
Length(ReturnResult) - IndyPos(' ', ReturnResult) + 1), -1);
end
else
Result := -1;
except
Result := -1;
end;
end;end.