{"record":{"id":"26d874b7894a2390","repo":"pentaho/pentaho-kettle","slug":"mailconnection-error-movingmessages","errorCode":null,"errorMessage":"MailConnection.Error.MovingMessages","messagePattern":"MailConnection\\.Error\\.MovingMessages","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/email-messages/impl/src/main/java/org/pentaho/di/job/entries/getpop/MailConnection.java","lineNumber":1362,"sourceCode":"    try {\n      if ( this.protocol == MailConnectionMeta.PROTOCOL_MBOX ) {\n        if ( this.destinationMboxPath == null ) {\n          throw new KettleException( BaseMessages.getString( PKG, ERROR_FOLDER_NOT_FOUND, \"\" ) );\n        }\n        appendMessagesToMbox( this.messages, this.destinationMboxPath );\n        deleteMessages( false );\n        setMovedMessagesCounter();\n        return;\n      }\n\n      this.folder.copyMessages( this.messages, this.destinationIMAPFolder );\n      deleteMessages( false );\n      setMovedMessagesCounter();\n    } catch ( Exception e ) {\n      String errorMessage = ( this.protocol == MailConnectionMeta.PROTOCOL_MBOX )\n        ? BaseMessages.getString( PKG, \"MailConnection.Error.MovingMessages\", this.destinationMboxPath )\n        : BaseMessages.getString( PKG, \"MailConnection.Error.MovingMessages\", this.destinationIMAPFolder.getName() );\n      throw new KettleException( errorMessage, e );\n    }\n  }\n\n  /**\n   * Check if a folder exists on server (only IMAP).\n   *\n   * @param foldername\n   *          the name of the folder\n   * @return true is folder exists\n   */\n  public boolean folderExists( String foldername ) {\n    if ( this.protocol == MailConnectionMeta.PROTOCOL_MBOX ) {\n      return new File( resolveMboxFolderPath( foldername ) ).exists();\n    }\n\n    boolean retval = false;\n    Folder dfolder = null;\n    try {","sourceCodeStart":1344,"sourceCodeEnd":1380,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/email-messages/impl/src/main/java/org/pentaho/di/job/entries/getpop/MailConnection.java#L1344-L1380","documentation":"moveMessages() wraps any Exception thrown while moving messages (appending to destination and deleting from source) in a KettleException with this message. It reports the destination folder name (mbox path or IMAP folder) plus the underlying cause.","triggerScenarios":"Any failure inside moveMessages(): appendMessagesToMbox() or deleteMessages() throwing, e.g. IO error writing the destination mbox, or MessagingException on the IMAP folder during copy/delete.","commonSituations":"Destination mbox file not writable or on a full disk; IMAP connection dropped mid-move; destination IMAP folder deleted by another client; message flags cannot be set.","solutions":["Inspect the wrapped cause (e.getCause()) for the real failure","Verify write permissions and free disk space on the destination mbox path","Reconnect/reopen the IMAP folder and retry the move","For IMAP, confirm the destination folder exists via folderExists()/createFolder() before moving"],"exampleFix":"// before\nconnection.moveMessages();\n// after\ntry {\n  connection.moveMessages();\n} catch ( KettleException e ) {\n  logError( \"Move failed: \" + e.getCause(), e ); // diagnose underlying IO/MessagingException\n}","handlingStrategy":"try-catch","validationCode":"if ( connection.getProtocol() == MailConnectionMeta.PROTOCOL_MBOX ) {\n  assert new java.io.File( connection.getDestinationMboxPath() ).getParentFile().canWrite();\n} else {\n  assert connection.folderExists( connection.getDestinationIMAPFolder().getName() );\n}","typeGuard":null,"tryCatchPattern":"try {\n  connection.moveMessages();\n} catch ( KettleException e ) {\n  Throwable cause = e.getCause();\n  logError( \"Move to \" + dest + \" failed: \" + cause, e );\n  // retry once after reconnecting\n}","preventionTips":["Verify destination folder exists and is writable before moving","Keep IMAP connections alive; avoid long pauses between fetch and move","Monitor disk space on mbox destinations"],"tags":["kettle","pdi","email","imap","mbox","io"],"backgroundTag":"file-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}