这是我写的一段代码,从没出现过乱码问题
procedure TForm1.ToolButton2Click(Sender: TObject);//收邮件
var
i:integer;
strmail:string;
begin
with nmpop31 do
begin
host:=edithost.Text;
port:=strtoint(edit2.text);
userid:=edituser.text;
password:=editpsw.text;
attachfilepath:='c:/';
deleteonread:=false;
reportlevel:=Status_Basic;
timeout:=20000;
connect;
if connected then
begin
if mailcount>0 then
begin
lstmail.Items.Clear;
for i:=1 to mailcount do
begin
strmail:='';
getsummary(i);
strmail:=summary.MessageId+' from : '+
summary.From +' : '+
summary.Subject+'.size: '+
inttostr(summary.Bytes);
lstmail.Items.add(strmail);
getmail(1);
statusbar1.SimpleText:='#of E-mail: '+inttostr(mailcount);
end;
end
end else
statusbar1.SimpleText:='Status : connection failed!';
end;
end;
procedure getmail(i:integer);
begin
with form1 do
begin
nmpop31.GetMailMessage(i);
txtfrom.Text:=nmpop31.MailMessage.From;
txtmessageid.Text:=nmpop31.MailMessage.MessageId;
txtsubject.Text:=nmpop31.MailMessage.Subject;
if nmpop31.MailMessage.Attachments.Text<>'' then
begin
lstattach.Items.Assign(nmpop31.MailMessage.Attachments);
end else
begin
lstattach.Visible:=false;
end;
txtheader.Lines.Assign(nmpop31.mailmessage.head);
txtbody.lines.Assign(nmpop31.mailmessage.body);
lblno.Caption:=inttostr(i);
end;
end;
第二个问题可以用多线程来解决