我要做一个邮件收发系统,
 1. 怎么才能和163的外寄邮件服务器建立连接?我邮箱是163的,发送邮件的协议: SMTP ,收邮件的协议: POP3
 2. 下面的代码是保存邮件附件:
void saveFile(int numAttach, String[] fileName, InputStream[] inputStream) {
// numAttach 附件的数目 fileName 文件的名称  inputStream  输入流
String filesep = System.getProperty("file.separator");
String sfile = "";
fileFileChooser.setCurrentDirectory(new File("."));
fileFileChooser.setDialogType(JFileChooser.DIRECTORIES_ONLY + JFileChooser.SAVE_DIALOG);
fileFileChooser.setDialogTitle("Select Directory");
if (fileFileChooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
    return;String pathName = fileFileChooser.getCurrentDirectory().getAbsolutePath();// 上面这行代码一直提示:代码不可达?
 这个问题怎么解决? 还有在JFileChooser 保存文件时,怎么在保存界面的文件名输入框中,自动设置要保存的文件名?this.repaint();try {
     for (int j = 0; j < numAttach; j++) {
    File file = new File(pathName + filesep + fileName[j]);
          FileWriter out = new FileWriter(file);
BufferedReader br = new BufferedReader(new InputStreamReader(inputStrea[j]));
BufferedWriter bw = new BufferedWriter(out);
String line;
while ((line = br.readLine()) != null) {
    bw.write(line);
    bw.newLine();
            }
    bw.flush();
    bw.close();
          out.close();
     }
}
     望各位高手指点迷津!!!! 不胜感激!!!

解决方案 »

  1.   

    因为这行代码上面有句return啊
      

  2.   

    呵呵,谢谢....
     还问一个问题,我发送邮件的协议是: STMP  接收邮件的协议是: POP3
    当我发送邮件的时候,Debug出现下面的异常:说是服务器连接失败,接收邮件也是这样的问题
    DEBUG: setDebug: JavaMail version 1.4ea
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "mail.163.com", port 25, isSSL false
    javax.mail.MessagingException: Unknown SMTP host: mail.163.com;
      nested exception is:
        java.net.UnknownHostException: mail.163.com
       就是这个外寄邮件服务器的问题怎么解决?
       期待回复!!!