用javamail 你看看它的例子,你是台湾人么?用繁体字??

解决方案 »

  1.   

    to->hexiaofeng(java爱好者) :在什么地方工作呢﹖
      

  2.   

    我建议你看看你所接收到的邮件的源代码。很容易就能够看出来他的语法的,
    具体的话你还是得去看看rfc得东西
      

  3.   

    请看 rfc  文档
    http://www.china-pub.com/computers/eMook/emooknew/RFC/rfc.asp
      

  4.   

        DataInputStream in=new DataInputStream(socket.getInputStream());
        DataOutputStream out = new DataOutputStream (socket.getOutputStream));    out.writeBytes("HELO "+"smtp.21cn.com");
        out.writeBytes("\n");
        String resu=in.readLine() ;
        System.out.println(resu) ;    out.writeBytes("MAIL FROM:"+"[email protected]");
        out.writeBytes("\n");
        resu=in.readLine();
        System.out.println(resu) ;    out.writeBytes("RCPT TO:"+"[email protected]");
        out.writeBytes("\n");
        resu=in.readLine();
        System.out.println(resu) ;    out.writeBytes("DATA");
        out.writeBytes("\n");
        resu=in.readLine();
        System.out.println(resu) ;    out.writeBytes("Subject:"+"aa");
        out.writeBytes("\n");    out.writeBytes("From:"+"[email protected]");
        out.writeBytes("\n");    out.writeBytes("To:"+"[email protected]");
        out.writeBytes("\n");   out.writeBytes("Content-Type: text/plain"+'\n');
       out.writeBytes("Content-Transfer-encoding: 8bit" + '\n');
       out.writeBytes("\n");
     
       out.writeBytes("Content-Type: multipart/mixed;"+
                       " boundary=\"ddd\""+'\n');
       out.writeBytes("--ddd"+'\n');
       String aaa="d:\\abc.txt";
       out.writeBytes("Content-Type: text/plain;"+"name="+"\""+aaa+"\""+"");
       out.writeBytes("\n");   out.writeBytes("Content-Transfer-Encoding: quoted-printable"+"\n") ;
       out.writeBytes("Content-Disposition: attachment;"+
                           "filename="+"\""+aaa+"\""+"\n") ;   File file=new File("d:\\abc.txt");
       BufferedInputStream input=new BufferedInputStream(new FileInputStream
                                                  (file));
       int result;
       while ((result=input.read())!=-1)
       {
         out.write(result)  ;
       }
       out.writeBytes("\n");
       resu=in.readLine();
       System.out.println(resu) ;   out.writeBytes("--ddd--"+'\n');
       out.writeBytes(".");
       out.writeBytes("\n");
       resu=in.readLine();
       System.out.println(resu) ;
       out.writeBytes("QUIT");
       resu=in.readLine();
       System.out.println(resu) ;
       socket.close() ;
       }catch(Exception e){
            System.out.println("closing....");
            e.printStackTrace() ;
       }
    以上是我的部分程序﹐為什么我發送過去的附件信息就是不能在郵件中于附件形式顯示呢﹖謝謝﹗﹗
      

  5.   

         DataInputStream in=new DataInputStream(socket.getInputStream());
         DataOutputStream out = new DataOutputStream(socket.getOutputStream());
        
            out.writeBytes("HELO "+"smtp.21cn.com");
            out.writeBytes("\n");
             String resu=in.readLine() ;
             System.out.println(resu) ;
            out.writeBytes("MAIL FROM:"+"[email protected]");
            out.writeBytes("\n");
           resu=in.readLine();
            System.out.println(resu) ;
           out.writeBytes("RCPT TO:"+"[email protected]");
           out.writeBytes("\n");
             resu=in.readLine();
             System.out.println(resu) ;
           out.writeBytes("DATA");
            out.writeBytes("\n");
          resu=in.readLine();
             System.out.println(resu) ;
            out.writeBytes("Subject:"+"aa");
            out.writeBytes("\n");
            out.writeBytes("From:"+"[email protected]");
            out.writeBytes("\n");        out.writeBytes("To:"+"[email protected]");
            out.writeBytes("\n");
         out.writeBytes("Content-Type: text/plain"+'\n');
            out.writeBytes("Content-Transfer-encoding: 8bit" + '\n');
            out.writeBytes("\n");
        out.writeBytes("Content-Type: multipart/mixed;"+
                       " boundary=\"ddd\""+'\n');
         out.writeBytes("--ddd"+'\n');
           String aaa="d:\\ypf\\dd.txt";
            out.writeBytes("Content-Type: text/plain;"+"name="+"\""+aaa+"\""+"");
            out.writeBytes("\n");
            out.writeBytes("Content-Transfer-Encoding: quoted-printable"+"\n") ;
            out.writeBytes("Content-Disposition: attachment;"+
                           "filename="+"\""+aaa+"\""+"\n") ;     File file=new File("d:\\ypf\\dd.txt");
         BufferedInputStream input=new BufferedInputStream(new FileInputStream
                                                  (file));
         int result;
         while ((result=input.read())!=-1)
         {
         out.write(result)  ;
         }
        out.writeBytes("\n");
         resu=in.readLine();
             System.out.println(resu) ;
        out.writeBytes("--ddd--"+'\n');
        out.writeBytes(".");
        out.writeBytes("\n");        resu=in.readLine();
             System.out.println(resu) ;
             out.writeBytes("QUIT");
                resu=in.readLine();
             System.out.println(resu) ;
          socket.close() ;
          }catch(Exception e){
            System.out.println("closing....");
            e.printStackTrace() ;
          }
      }
    }
    以上是我的部分程序﹐為什么我的附件信息發過去后﹐就是不能用附件形式顯示呢﹖