在使用delphi6的TIdmessage和TIdpop3控件来接收邮件,接收到中文的时出现乱码,该如何处理?????
代码如下:
//接收邮件信息
pop.Retrieve(intIndex,Msg);
itm := listview1.Items.Add;
itm.ImageIndex := 5;
itm.Caption := Msg.Subject;
itm.SubItems.Add(Msg.From.Text);
itm.SubItems.Add(DateTimeToStr(Msg.Date));
itm.SubItems.Add(IntToStr(POP.RetrieveMsgSize(intIndex))); 接收到的Msg.subject等信息出现乱码"=?gb2312?B?T6...."
代码如下:
//接收邮件信息
pop.Retrieve(intIndex,Msg);
itm := listview1.Items.Add;
itm.ImageIndex := 5;
itm.Caption := Msg.Subject;
itm.SubItems.Add(Msg.From.Text);
itm.SubItems.Add(DateTimeToStr(Msg.Date));
itm.SubItems.Add(IntToStr(POP.RetrieveMsgSize(intIndex))); 接收到的Msg.subject等信息出现乱码"=?gb2312?B?T6...."
解决方案 »
- delphi的前景怎么样?
- 【上海求职】Delphi 程序员
- BDE设置问题,高手帮忙.这个问题困扰我很久了.
- SMTP中有提到8BITMIME, 难道还有不同的MIME?
- 高手请进:数据库中一个字段定义成NUMBER(20)了,插入记录时,如果传参数ASINTEGER要溢出,有没有办法解决?
- 关于DBGrideh结果集复制,拷贝到Excel的问题。在线等。
- 我现在是有个标志字段,根据它的值而改变本条纪录在dbgrid中的显示颜色。现在当前选择行默认为 蓝色,我想改变这个颜色
- 使用特定控件,在安装程序制作时要注意哪些?
- DELPHI 中的饼图控件怎么个部份家起来不等于己于人100%呢
- web开发CGI的错误!
- 请问哪里有Btrieve 数据库ODBC驱动下载?
- BDE 连接失败过多的问题
var
s1,s2,s3: integer;
t,v: string;
Encoding: char;
hex,step: integer;
a1: array[1..4] of byte;
b1: array[1..3] of byte;
j: integer;
byte_ptr,real_bytes: integer;
begin
s1:=Pos('=?',s);
s2:= 1 ;
hex:= 0 ;
if s1>0 then
begin
for s2:=Length(s)-1 downto 1 do
begin
if Copy(s,s2,2)='?=' then Break;
end;
end;
if (s1=0) or (s2=1) then
begin
Result:=s;
Exit;
end;
t:=Copy(s,s1+2,s2-2-s1);
s3:=Pos('?',t);
Delete(t,1,s3);
if(t='')then
begin
Result:= s;
Exit ;
end ;
Encoding:=t[1];
Delete(t,1,2);
v:='';
step:=0;
case Encoding of
'Q':
while t<>'' do
begin
case step of
0:
begin
case t[1] of
'_': v:=v+' ';
'=': step:=1;
else v:=v+t[1];
end;
end;
1:
begin
if t[1]<='9' then hex:=(Ord(t[1])-Ord('0'))*16
else hex:=(Ord(t[1])-55)*16;
step:=2;
end;
2:
begin
if t[1]<='9' then hex:=hex+(Ord(t[1])-Ord('0'))
else hex:=hex+Ord(t[1])-55;
v:=v+Chr(hex);
step:=0;
end;
end;
Delete(t,1,1);
end;
'B':
begin
byte_ptr:=0;
for j:=1 to Length(t) do
begin
Inc(byte_ptr);
case t[j] of
'A'..'Z': a1[byte_ptr]:=Ord(t[j])-65;
'a'..'z': a1[byte_ptr]:=Ord(t[j])-71;
'0'..'9': a1[byte_ptr]:=Ord(t[j])+4;
'+': a1[byte_ptr]:=62;
'/': a1[byte_ptr]:=63;
'=': a1[byte_ptr]:=64;
end;
if byte_ptr=4 then
begin
byte_ptr:=0;
real_bytes:=3;
if a1[1]=64 then real_bytes:=0;
if a1[3]=64 then
begin
a1[3]:=0;
a1[4]:=0;
real_bytes:=1;
end;
if a1[4]=64 then
begin
a1[4]:=0;
real_bytes:=2;
end;
b1[1]:=a1[1]*4+(a1[2] div 16);
b1[2]:=(a1[2] mod 16)*16+(a1[3]div 4);
b1[3]:=(a1[3] mod 4)*64 +a1[4];
if(real_bytes>0)then
v:= v + chr(b1[1]) ;
if(real_bytes>1)then
v:= v + chr(b1[2]) ;
if(real_bytes>2)then
v:= v + chr(b1[3]) ;
end;
end;
end;
end;
Result := v;
end;