http://expert.csdn.net/Expert/topic/1177/1177970.xml?temp=.4810297看看对你有帮助没?

解决方案 »

  1.   

    谢谢 yihua_cai(灵犀指) ,那篇文章我看了,但它只发送了一个附件,我要多个
      

  2.   

    把你需要发送的多个附件的文件路径保存在一个用逗号割开的文本框中,发送的时候用分别提取单个文件路径,在使用循环,就可以发送多了附件了
    在http://www-900.ibm.com/developerWorks/cn上有个关于JavaMail的教程,可以看看
      

  3.   

    MimeMessage mimemessage = new MimeMessage(session);
              //声明存储文字内容的变量
              MimeBodyPart mimebodypart = new MimeBodyPart();
              mimebodypart.setContent(message.getText().toString(), "text/plain;charset=Gb2312");          MimeMultipart mimemultipart = new MimeMultipart();
              mimemultipart.addBodyPart(mimebodypart);  //加入文字内容            //声明存储附件内容的变量
              MimeBodyPart mimebodypart1;
              FileDataSource filedatasource;
              //逐个加入附件
              for (int i = 0; i < attachFile.length; i++) {
                mimebodypart1 = new MimeBodyPart();
                filedatasource = new FileDataSource(attachFile[i].toString());
                mimebodypart1.setDataHandler(new DataHandler(filedatasource));
                mimebodypart1.setFileName(filedatasource.getName());
                mimemultipart.addBodyPart(mimebodypart1);
              }
              mimemessage.setContent(mimemultipart);    //加入全部附件内容