{"record":{"id":"b5b66b13c8542f83","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotfindattachedcontentfilenamefield","errorCode":null,"errorMessage":"Mail.Exception.CouldnotFindAttachedContentFileNameField","messagePattern":"Mail\\.Exception\\.CouldnotFindAttachedContentFileNameField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":429,"sourceCode":"      if ( Utils.isEmpty( attachedContentField ) ) {\n        // Empty Field\n        throw new KettleException( BaseMessages.getString( PKG, \"Mail.Exception.AttachedContentFieldEmpty\" ) );\n      }\n      data.indexOfAttachedContent = data.previousRowMeta.indexOfValue( attachedContentField );\n      if ( data.indexOfAttachedContent < 0 ) {\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.CouldnotFindAttachedContentField\", attachedContentField ) );\n      }\n      // Attached content filename\n      String attachedContentFileNameField = meta.getAttachContentFileNameField();\n      if ( Utils.isEmpty( attachedContentFileNameField ) ) {\n        // Empty Field\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.AttachedContentFileNameFieldEmpty\" ) );\n      }\n      data.IndexOfAttachedFilename = data.previousRowMeta.indexOfValue( attachedContentFileNameField );\n      if ( data.IndexOfAttachedFilename < 0 ) {\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.CouldnotFindAttachedContentFileNameField\", attachedContentFileNameField ) );\n      }\n    } else {\n\n      // Dynamic Zipfilename\n      if ( meta.isZipFilenameDynamic() ) {\n        // cache the position of the attached source filename field\n        if ( data.indexOfDynamicZipFilename < 0 ) {\n          String realZipFilename = meta.getDynamicZipFilenameField();\n          data.indexOfDynamicZipFilename = data.previousRowMeta.indexOfValue( realZipFilename );\n          if ( data.indexOfDynamicZipFilename < 0 ) {\n            throw new KettleException( BaseMessages.getString(\n              PKG, \"Mail.Exception.CouldnotSourceAttachedZipFilenameField\", realZipFilename ) );\n          }\n        }\n      }\n      data.zipFileLimit = Const.toLong( environmentSubstitute( meta.getZipLimitSize() ), 0 );\n      if ( data.zipFileLimit > 0 ) {","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L411-L447","documentation":"'Attach content from field' is enabled and both required field names were set, but the attached-content filename field does not exist in the incoming row. The indexOfValue lookup in cacheFieldsPosition returned -1 and this KettleException is thrown.","triggerScenarios":"meta.isAttachContentFromField() is true, attachedContentFileNameField is non-empty, and data.previousRowMeta.indexOfValue(attachedContentFileNameField) < 0.","commonSituations":"Filename field name typo; upstream step renamed the filename column; step copied between transformations with different schemas.","solutions":["Check the attachment filename field name in the Mail step against the actual input stream fields (exact, case-sensitive match).","Preview the upstream hop to verify the filename field is produced.","Disable 'Attach content from field' to attach physical files instead."],"exampleFix":"// before\n// attachContentFileNameField = \"filename\" but stream field is \"report_name\"\n// after\n// meta.setAttachContentFileNameField(\"report_name\");","handlingStrategy":"validation","validationCode":"if (meta.isAttachContentFromField()\n    && meta.getAttachContentFileNameField() != null && !meta.getAttachContentFileNameField().isEmpty()\n    && rowMeta.indexOfValue(meta.getAttachContentFileNameField()) < 0) {\n  throw new KettleException(\"Attached content filename field not found: \" + meta.getAttachContentFileNameField());\n}","typeGuard":null,"tryCatchPattern":"try { sendMail(); } catch (KettleException e) { if (e.getMessage().contains(\"CouldnotFindAttachedContentFileNameField\")) { logError(\"Attachment filename field not present in the input stream\"); } throw e; }","preventionTips":["Ensure an upstream step produces the attachment filename column.","Preview rows after schema changes to catch renamed fields early.","Use the dialog's field dropdown so names always match the stream exactly."],"tags":["kettle","pentaho","mail-step","attachments"],"backgroundTag":"field-not-found-in-row","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"}