您的位置:程序门 -> delphi -> 网络通信/分布式开发



delphi7 邮件接收body乱码


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


delphi7 邮件接收body乱码
发表于:2008-01-12 10:35:03 楼主
我现用delphi7写一个邮件收发程序,用的是idpop3,idsmtp,idmessage控件.
收到的有些信件不能正常显示如下.
content-type:   text/html;   charset="gbk"   content-transfer-encoding:   base64   sk7xqr3hdqo8relwprcu16q9x7cu16q9x7cu16q9x7cu16q9x7cu16q9x7cu16q9x7cu16q9   x7cu16q9x7cu16q9xzwvrelwpg==
 
发表于:2008-01-12 10:36:541楼 得分:0
刚注册,不知道能不能给分!!!!!!!!!
发表于:2008-01-13 11:50:432楼 得分:0
你这个是加了密的。用的是base64加密方式
代码如下:
function   base64encode(const   s:   string):   string;
var
      i,c1,c2,c3:   integer;
      m,n:   integer;
const
      base64:   string   =   'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/';
begin
      result   :=   '';
      m:=1;
      n:=0;
      for   i   :=   1   to   (length(s)   div   3)   do
      begin
          c1   :=   ord(s[m]);
          c2   :=   ord(s[m+1]);
          c3   :=   ord(s[m+2]);
          m:=m+3;
          result   :=   result+base64[(c1   shr   2)and   $3f+1];
          result   :=   result+base64[((c1   shl   4)and   $30)   or   ((c2   shr   4)and   $0f)+1];
          result   :=   result+base64[((c2   shl   2)and   $3c)   or   ((c3   shr   6)and   $03)+1];
          result   :=   result+base64[c3   and   $3f+1];
          n:=n+4;
          if(n   =   76)then
          begin
                n:=0;
                result   :=   result+#13#10;
          end;
      end;
      if   (length(s)   mod   3)=1   then
      begin
          c1   :=   ord(s[m]);
          result   :=   result+base64[(c1   shr   2)and   $3f+1];
          result   :=   result+base64[(c1   shl   4)and   $30+1];
          result   :=   result+'=';
          result   :=   result+'=';
      end;
      if   (length(s)   mod   3)=2   then
      begin
          c1   :=   ord(s[m]);
          c2   :=   ord(s[m+1]);
          result   :=   result+   base64[(c1   shr   2)and   $3f+1];
          result   :=   result+   base64[((c1   shl   4)and   $30)   or   ((c2   shr   4)and   $0f)+1];
          result   :=   result+base64[(c2   shl   2)and   $3c+1];
          result   :=   result+   '=';
      end;
end;

function   base64decode(const   s:   string):   string;
var
      i,m,n:   integer;
      c1,c2,c3,c4:   integer;
const
      base64:   string   =   'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/';
begin
      result   :=   '';
      n:=1;
      m:=length(s);
      if   s[m]='='then   m:=m-1;
      if   s[m]='='then   m:=m-1;
      for   i:=1   to   m   div   4   do
      begin
          c1:=pos(s[n],base64)-1;
          c2:=pos(s[n+1],base64)-1;
          c3:=pos(s[n+2],base64)-1;
          c4:=pos(s[n+3],base64)-1;
          n:=n+4;
          result:=result+chr(((c1   shl   2)and   $fc)or((c2   shr   4)and   $3));
          result:=result+chr(((c2   shl   4)and   $f0)or((c3   shr   2)and   $0f));
          result:=result+chr(((c3   shl   6)and   $c0)or   c4);
      end;
      if   m   mod   4=2   then
      begin
          c1:=pos(s[n],base64)-1;
          c2:=pos(s[n+1],base64)-1;
          result:=result+chr(((c1   shl   2)and   $fc)or((c2   shr   4)and   $3));
      end;

      if   m   mod   4=3   then
      begin
          c1:=pos(s[n],base64)-1;
          c2:=pos(s[n+1],base64)-1;
          c3:=pos(s[n+2],base64)-1;
          result:=result+chr(((c1   shl   2)and   $fc)or((c2   shr   4)and   $3));
          result:=result+chr(((c2   shl   4)and   $f0)or((c3   shr   2)and   $0f));
      end;

end;
发表于:2008-01-13 19:46:053楼 得分:0
解密就行
发表于:2008-01-15 08:35:214楼 得分:0
学习
发表于:2008-01-16 16:44:335楼 得分:0
对解密就行.


快速检索

最新资讯
热门点击