以下是我编的程序:
with IdMsgSend do
   begin
    Subject := sSubject; //邮件主题
    Body.text :='testtest';
    From.Text :='[email protected]'; //发信人地址
   // Recipients.EMailAddresses :=trim(edtTo.Text); //收件人地址
   Recipients.EMailAddresses :='[email protected]'; //收件人地址
   end; 
with IdSMTP1 do
   begin
      Host:='smtp.corpease.net'; 
      AuthenticationType:=atLogin;
      Port:=25; //SMTP服务器端口
      UserName:='****'; //用户账号
      Password:='***'; // 用户密码
   end;
    try
        IdSMTP1.Connect(); //调用 Connect连接服务器
    except //连接失败
        MessageBox(0,'无法连接到服务器!','错误',MB_OK or MB_ICONERROR);
        Exit;
     end;
//发送信件
    try
        IdSMTP1.Authenticate;
        IdSMTP1.Send(IdMsgSend);
    except
        MessageBox(0,'发送失败!','错误',MB_OK or MB_ICONERROR);
        IdSMTP1.Disconnect;
        exit;
    end;
      IdSMTP1.Disconnect;接收的时候,正文显示为:
=?GB2312?B?MDA4xOoxMNTCKQ==?=
To: [email protected]
Date: Thu, 26 Jun 2008 11:14:19 +0800
X-Priority: 3
X-Library: Indy 9.00.10
testtest请问是什么错误。

解决方案 »

  1.   

    一点都没有错啊
    因为你没有解码。
    =?GB2312MDA4xOoxMNTCKQ==?= 
    ?B?代表  Base64,你可以去看看解码的帖子,这个上面也有很多,找不到再问我要吧
      

  2.   

    算了,还是用调用outlook来发好了
      

  3.   

    unit   Base64Code;
        
      interface   
        
      uses   
          Windows,   SysUtils, Classes,  StrUtils ,IdCoderQuotedPrintable,IdCoderMIME;
        
          Function   GetMailTitle(Const   Value:   String):   String;
          Function   GetMailSender(Const   value:   String):String;
          const   cBase64:string='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
      implementation  Function   QuotedPrintableEncode(mSource:   String):   String;   
      Var   
          I,   J:   Integer;   
      Begin   
          Result   :=   '';   
          J   :=   0;   
          For   I   :=   1   To   Length(mSource)   Do   Begin   
                  If   mSource[I]   In   [#32..#127,   #13,   #10]   -   ['=']   Then   Begin   
                          Result   :=   Result   +   mSource[I];   
                          Inc(J);   
                      End   Else   Begin   
                          Result   :=   Result   +   '='   +   IntToHex(Ord(mSource[I]),   2);   
                          Inc(J,   3);   
                      End;   
                  If   mSource[I]   In   [#13,   #10]   Then   J   :=   0;   
                  If   J   >=   70   Then   Begin   
                          Result   :=   Result   +   #13#10;   
                          J   :=   0;   
                      End;   
              End;   
      End;   {   QuotedPrintableEncode   }   
        
      Function   QuotedPrintableDecode(mCode:   String):   String;   
      Var   
          I,   J,   L:   Integer;   
      Begin   
          Result   :=   '';   
          J   :=   0;   
          mCode   :=   AdjustLineBreaks(mCode);   
          L   :=   Length(mCode);   
          I   :=   1;   
          While   I   <=   L   Do   Begin   
                  If   mCode[I]   =   '='   Then   Begin   
                          Result   :=   Result   +   Chr(StrToIntDef('$'   +   Copy(mCode,   I   +   1,   2),   0));   
                          Inc(J,   3);   
                          Inc(I,   3);   
                      End   Else   If   mCode[I]   In   [#13,   #10]   Then   Begin   
                          If   J   <   70   Then   Result   :=   Result   +   mCode[I];   
                          If   mCode[I]   =   #10   Then   J   :=   0;   
                          Inc(I);   
                      End   Else   Begin   
                          Result   :=   Result   +   mCode[I];   
                          Inc(J);   
                          Inc(I);   
                      End;   
              End;   
      End;   {   QuotedPrintableDecode   }   
        
      Function   Base64Encode(mSource:   String;   mAddLine:   Boolean   =   True):   String;   
      Var   
          I,   J:   Integer;   
          S:   String;   
      Begin   
          Result   :=   '';   
          J   :=   0;   
          For   I   :=   0   To   Length(mSource)   Div   3   -   1   Do   Begin   
                  S   :=   Copy(mSource,   I   *   3   +   1,   3);   
                  Result   :=   Result   +   cBase64[Ord(S[1])   Shr   2   +   1];   
                  Result   :=   Result   +   cBase64[((Ord(S[1])   And   $03)   Shl   4)   +   (Ord(S[2])   Shr   4)   +   1];   
                  Result   :=   Result   +   cBase64[((Ord(S[2])   And   $0F)   Shl   2)   +   (Ord(S[3])   Shr   6)   +   1];   
                  Result   :=   Result   +   cBase64[Ord(S[3])   And   $3F   +   1];   
                  If   mAddLine   Then   Begin   
                          Inc(J,   4);   
                          If   J   >=   76   Then   Begin   
                                  Result   :=   Result   +   #13#10;   
                                  J   :=   0;   
                              End;   
                      End;   
              End;   
          I   :=   Length(mSource)   Div   3;   
          S   :=   Copy(mSource,   I   *   3   +   1,   3);   
          Case   Length(S)   Of   
              1:   Begin   
                      Result   :=   Result   +   cBase64[Ord(S[1])   Shr   2   +   1];   
                      Result   :=   Result   +   cBase64[(Ord(S[1])   And   $03)   Shl   4   +   1];   
                      Result   :=   Result   +   cBase64[65];   
                      Result   :=   Result   +   cBase64[65];   
                  End;   
              2:   Begin   
                      Result   :=   Result   +   cBase64[Ord(S[1])   Shr   2   +   1];   
                      Result   :=   Result   +   cBase64[((Ord(S[1])   And   $03)   Shl   4)   +   (Ord(S[2])   Shr   4)   +   1];   
                      Result   :=   Result   +   cBase64[(Ord(S[2])   And   $0F)   Shl   2   +   1];   
                      Result   :=   Result   +   cBase64[65];   
                  End;   
          End;   
      End;   {   Base64Encode   }   
        
      Function   Base64Decode(mCode:   String):   String;   
      Var   
          I,   L:   Integer;   
          S:   String;   
      Begin   
          Result   :=   '';   
          L   :=   Length(mCode);   
          I   :=   1;   
          While   I   <=   L   Do   Begin   
                  If   Pos(mCode[I],   cBase64)   >   0   Then   Begin   
                          S   :=   Copy(mCode,   I,   4);   
                          If   (Length(S)   =   4)   Then   Begin   
                                  Result   :=   Result   +   Chr((Pos(S[1],   cBase64)   -   1)   Shl   2   +   
                                      (Pos(S[2],   cBase64)   -   1)   Shr   4);   
                                  If   S[3]   <>   cBase64[65]   Then   Begin   
                                          Result   :=   Result   +   Chr(((Pos(S[2],   cBase64)   -   1)   And   $0F)   Shl   4   +   
                                              (Pos(S[3],   cBase64)   -   1)   Shr   2);   
                                          If   S[4]   <>   cBase64[65]   Then   
                                              Result   :=   Result   +   Chr(((Pos(S[3],   cBase64)   -   1)   And   $03)   Shl   6   +   
                                                  (Pos(S[4],   cBase64)   -   1));   
                                      End;   
                              End;   
                          Inc(I,   4);   
                      End   Else   Inc(I);   
              End;   
      End;   {   Base64Decode   }   
        
      Function   GetMailTitle(Const   Value:   String):   String;   
      Var   
          iPos:   integer;   
      Begin   
          Result   :=   Value;   
    //      If   Copy(Value,   1,   2)   <>   '=?'   Then
    //          Begin   
    //              Result   :=   Value;   
    //              exit;   
    //          End;   
          //'?B?'前面的都要去掉
          iPos   :=   Pos('?B?',   Value);   
          If   iPos   =   0   Then   
              Begin   
                  iPos   :=   Pos('?Q?',   Value);   
                  If   iPos   =   0   Then   
                      Begin   
                          Result   :=   Value;   
                          exit;   
                      End;   
                  Inc(iPos,   3);   
          //最后的'?='也要去掉   
                  Result   :=   Copy(Value,   iPos,   Length(Value)   -   iPos   -   1);   
                  Result   :=   QuotedPrintableDecode(Result);
              End   
          Else
              Begin   
                  Inc(iPos,   3);   
          //最后的'?='也要去掉   
                  Result   :=   Copy(Value,   iPos,   Length(Value)   -   iPos   -   1);   
                  Result   :=   Base64Decode(Result);   
              End;   
        
      End;   
      //由于发件人是中文+'<[email protected]>',组成的,所以多加了这个函数!   
      Function   GetMailSender(Const   value:   String):String;
      var   
          iPos:integer;   
          preStr:String;   
          bkStr:String;   
      begin   
          Result:=   value;
          If   Copy(Value,   1,   2)   <>   '=?'   Then
              Begin
                  Result   :=   Value;
                  exit;
              End;   
          iPos   :=   Pos('?= <',   Value);
          if   iPos=0   then
              begin
                  Result   :=   Value;   
                  exit;
              end   
          else
              begin   
                  preStr:=Copy(Value,1,iPos+1);
                  bkStr:=Copy(Value,iPos+2,length(Value)-iPos+2);   
                  Result:=   GetMailTitle(preStr)+   bkStr;   
              end;   
      end;end.
      

  4.   

    http://www.faqs.org/rfcs/rfc2047.html
      

  5.   

    调用outlook来发好了.
    最近忙毕业,差点忘了结贴了