function ReceiveMail(NMPOP3:TNMPOP3):boolean; var inifile:TIniFile; str:string; i,j:integer; Path:string;begin try try path := ExtractFilePath(Application.ExeName); inifile:= TIniFile.Create(path+'maillist.ini'); str := inifile.ReadString('receive','receiveaddress',''); NMPOP3.Host:= str; str:= inifile.ReadString('receive','receiveport',''); NMPOP3.Port := strtoint(trim(str)); str:= inifile.ReadString('receive','PassWord',''); NMPOP3.Password:= str; str := inifile.ReadString('receive','UserId',''); NMPOP3.UserID := str; if not NMPOP3.Connected then NMPOP3.Connect; NMPOP3.AttachFilePath := path+'SycData\';//这里自己加上存放的位置
NMPOP3.List; for i:= NMPOP3.MailCount downto 1 do // for j:= 1 to 500 do begin if NMPOP3.GetMailMessage(i); except ON E:EXCEPTION do begin raise E.CreateFmt('接收邮件出错,请重新接收',[]); end; end; finally inifile.Free end;
var
inifile:TIniFile;
str:string;
i,j:integer;
Path:string;begin
try
try
path := ExtractFilePath(Application.ExeName);
inifile:= TIniFile.Create(path+'maillist.ini');
str := inifile.ReadString('receive','receiveaddress','');
NMPOP3.Host:= str;
str:= inifile.ReadString('receive','receiveport','');
NMPOP3.Port := strtoint(trim(str));
str:= inifile.ReadString('receive','PassWord','');
NMPOP3.Password:= str;
str := inifile.ReadString('receive','UserId','');
NMPOP3.UserID := str; if not NMPOP3.Connected then
NMPOP3.Connect; NMPOP3.AttachFilePath := path+'SycData\';//这里自己加上存放的位置
NMPOP3.List; for i:= NMPOP3.MailCount downto 1 do
// for j:= 1 to 500 do
begin
if
NMPOP3.GetMailMessage(i); except
ON E:EXCEPTION do
begin
raise E.CreateFmt('接收邮件出错,请重新接收',[]);
end;
end;
finally
inifile.Free
end;