jmail收信的乱码问题该如何处理???急救

解决方案 »

  1.   

    你最好查看一下email的编码是什么,然后用相应的编码进行转换。
      

  2.   

    用jmail收附件就可以了,其他的可以socket端口110的方式来接收!
      

  3.   

    我是想将服务器上的邮件直接下载到本地,在subject上出现了乱码,还有附件该怎么处理呢?
      

  4.   

    好像有的是QP,有的是base64邮件这块很麻烦的
      

  5.   

    void uqp(unsigned char sour,unsigned char first,unsigned char second)
    /*
      sour:解码后的字符
      first:QP码的第一个字符
       second:QP码的第二个字符
      sour为返回值
    */
    {
     if(first>=65) first-=55;
     else first-=48;
     if(second>=65) second-=55;
     else second-=48;
     sour=NULL;
     sour=first<<4;
     sour|=second;
    }这个是c的,网上找来找去就这个了
    大大解释下啊,要不改成c#的啊
      

  6.   

    直接收成*.eml格式好了。使用下面的代码转换一下。
    StreamWriter sr =new StreamWriter(strpath+FILE_NAME,false,Encoding.GetEncoding("GB2312"));
    sr.WriteLine(JMsg.Text.ToString());
      

  7.   

    请问怎么收成eml格式的?
    能不能给段代码啊?
      

  8.   

    给你一段Delphi的
    function CheckTxt(const src: string): string;      //解码函数
    var
      i,pos1,pos2,pos3:integer;
      post:string;
      srclist:TStringList;  function Decoder(const s:string):string;
      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;
        tempedit:TEdit;
      begin
        s1:=Pos('=?',s);
        s2:= 1 ;
        hex:= 0 ;
        if s1>0 then
           for s2:=Length(s)-1 downto 1 do
             if Copy(s,s2,2)='?=' then Break;
        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:=Copy(s,1,s1-1)+v+Copy(s,s2+2,999);    tempedit:=TEdit.Create(nil);
        try
          tempedit.Width:=0;
          tempedit.Height:=0;
          tempedit.Visible:=True;
          tempedit.Text:=Result;
          Result:=tempedit.Text;
        finally
          FreeAndNil(tempedit);
        end;
        if Pos('***SPAM***',Result)>0 then
           result:=copy(result,pos('-',result)+1,length(result)-pos('-',result));
      end;
    begin
      pos1:=Pos('=?',src);
      pos2:= 1 ;
      if pos1>0 then
         for pos2:=Length(src)-1 downto 1 do
           if Copy(src,pos2,2)='?=' then Break;
      if (pos1=0) or (pos2=1) then
         begin
           Result:=src;
           Exit;
         end;  post:=Copy(src,pos1+2,pos2-2-pos1);
      pos3:=Pos('?',post);
      Delete(post,1,pos3);
      if(post='')then
        begin
          Result:=src;
          Exit ;
        end ;  srclist:=TStringList.Create;
      try
        srclist.Clear;
        StrtoStrlist(' ',src,srclist);
        Result:='';
        for i:=0 to srclist.Count-1 do
          begin
            post:=srclist.Strings[i];
            Result:=Result+Decoder(post);
          end;
      finally
        srclist.Free;
      end;
    end;
      

  9.   

    看不懂也帮不了你了,这个函数还没见有C#的,只见过有vc和delphi的,自己把它转成C#的或用vc或delphi实现你的功能吧
      

  10.   


    http://community.csdn.net/Expert/topic/4819/4819316.xml?temp=.2004969
    上有几个c#的解码,不过编出来还是乱码