{"record":{"id":"b7b70f8e3b12867d","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotfindattachedcontentfield","errorCode":null,"errorMessage":"Mail.Exception.CouldnotFindAttachedContentField","messagePattern":"Mail\\.Exception\\.CouldnotFindAttachedContentField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":417,"sourceCode":"        data.indexOfComment = data.previousRowMeta.indexOfValue( realComment );\n        if ( data.indexOfComment < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"Mail.Exception.CouldnotFindCommentField\", realComment ) );\n        }\n      }\n    }\n\n    if ( meta.isAttachContentFromField() ) {\n      // We are dealing with file content directly loaded from file\n      // and not physical file\n      String attachedContentField = meta.getAttachContentField();\n      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() ) {","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L399-L435","documentation":"'Attach content from field' is enabled and a content field name was configured, but no field with that name exists in the incoming row. cacheFieldsPosition throws this KettleException because indexOfValue returned -1 for meta.getAttachContentField().","triggerScenarios":"meta.isAttachContentFromField() is true, the configured attachContentField is non-empty, and data.previousRowMeta.indexOfValue(attachedContentField) < 0.","commonSituations":"Typo in the content field name; upstream step that produced the content field removed; field renamed during transformation refactor.","solutions":["Verify the 'Content field' name in the attachment settings exactly matches a field in the input stream.","Preview upstream rows to confirm the content field reaches the Mail step.","Disable 'Attach content from field' if attachments should come from files."],"exampleFix":"// before\n// attachContentField = \"content\" but stream field is \"file_content\"\n// after\n// meta.setAttachContentField(\"file_content\");","handlingStrategy":"validation","validationCode":"if (meta.isAttachContentFromField()\n    && meta.getAttachContentField() != null && !meta.getAttachContentField().isEmpty()\n    && rowMeta.indexOfValue(meta.getAttachContentField()) < 0) {\n  throw new KettleException(\"Attached content field not found: \" + meta.getAttachContentField());\n}","typeGuard":null,"tryCatchPattern":"try { sendMail(); } catch (KettleException e) { if (e.getMessage().contains(\"CouldnotFindAttachedContentField\")) { logError(\"Content field name does not match any input stream field\"); } throw e; }","preventionTips":["Preview the incoming hop to confirm the content field exists before attaching from fields.","Pick the content field from the dropdown, not by typing.","Update step settings whenever upstream field names change."],"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"}