Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用maven javax接收邮件?_Java_Maven_Javafx - Fatal编程技术网

如何使用maven javax接收邮件?

如何使用maven javax接收邮件?,java,maven,javafx,Java,Maven,Javafx,我想使用javafx从任何指定的电子邮件id接收邮件,但得到的异常是MojoExecutionException。 下面提供了我的pom.xml依赖项和全部源代码,请帮助我解决这个问题 <dependencies> <dependency> <groupId>javax.mail</groupId> <artifactId>javax.mail-api</artifactId>

我想使用javafx从任何指定的电子邮件id接收邮件,但得到的异常是MojoExecutionException。 下面提供了我的pom.xml依赖项和全部源代码,请帮助我解决这个问题

<dependencies>

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.5.0-b01</version>
        <type>jar</type>
    </dependency>
    <dependency>
<groupId>org.jvnet.mock-javamail</groupId>
<artifactId>mock-javamail</artifactId>
<version>1.9</version>

javax.mail
javax.mail-api
1.5.0-b01
罐子
org.jvnet.mock-javamail
模拟javamail
1.9

我的Javax代码是

 try {


 Properties properties = new Properties();  
 properties.put("mail.pop3.host", pop3Host);  
 Session emailSession = Session.getDefaultInstance(properties);  

POP3Store emailStore = (POP3Store) emailSession.getStore(storeType);  
emailStore.connect(user, password);  

 //3) create the folder object and open it  
 Folder emailFolder = emailStore.getFolder("INBOX");  
 emailFolder.open(Folder.READ_ONLY);  

 //4) retrieve the messages from the folder in an array and print it  
  Message[] messages = emailFolder.getMessages();  
 for (int i = 0; i < messages.length; i++) {  
 Message message = messages[i];  
 System.out.println("---------------------------------");  
 System.out.println("Email Number " + (i + 1));  
 System.out.println("Subject: " + message.getSubject());  
 System.out.println("From: " + message.getFrom()[0]);  
 System.out.println("Text: " + message.getContent().toString());  
 }  

 //5) close the store and folder objects  
 emailFolder.close(false);  
 emailStore.close();  

  } catch (NoSuchProviderException e) {e.printStackTrace();}   
  catch (MessagingException e) {e.printStackTrace();}  
 catch (IOException e) {e.printStackTrace();}  
}  

public  void excute() throws MessagingException {  

 String host = "xyz.com";//change accordingly  
 String mailStoreType = "pop3";  
 String username= "xyz@pqr.com";  
  String password= "cccccc";  

 receiveEmail(host, mailStoreType, username, password);  

 }  
public void start(Stage stage) throws Exception {

Parent root=FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));

    Scene scene = new Scene(root);
    scene.getStylesheets().add("/styles/Styles.css");

    stage.setTitle("JavaFX and Maven");
    stage.setScene(scene);
    stage.show();
  }
  public static void main(String[] args) throws MessagingException {
     receiveEmail obj=new receiveEmail();
     obj.excute();
     launch(args);
  }
试试看{
属性=新属性();
properties.put(“mail.pop3.host”,pop3Host);
会话emailSession=Session.getDefaultInstance(属性);
POP3Store emailStore=(POP3Store)emailSession.getStore(storeType);
emailStore.connect(用户、密码);
//3) 创建文件夹对象并将其打开
文件夹emailFolder=emailStore.getFolder(“收件箱”);
emailFolder.open(文件夹只读);
//4) 从数组中的文件夹中检索邮件并打印
Message[]messages=emailFolder.getMessages();
对于(inti=0;i
请发布您收到的完整错误。我在运行代码后收到此错误:无法在project send\u recv\u sms上执行目标org.codehaus.mojo:exec maven插件:1.2.1:exec(默认cli):命令执行失败。进程退出时出现错误:1(退出值:1)->[Help 1]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。使用-X开关重新运行Maven以启用完全调试日志记录。有关错误和可能的解决方案的更多信息,请阅读以下文章:[帮助1]