# Syntax Results from queries containing documents in binary or text format can be exported to output files using the syntax: ``` local export documents in <COLUMN-NAME> to "<DIRECTORY>" filename (automatic|column <COLUMN-NAME>) [actions <ACTION1>[,<ACTION2]*] ``` The document contents are retrieved from the column `COLUMN-NAME` and save in the specified directory. One output file is created per row. The name of the output files can be automatically generated or retrieved from another column. ## Automatic Filename Generation The automatic generation process of file names tries to detect the MIME type of each document to determine the extension. `txt` is used as extension when the extension can not be determined. The documents are numbered sequentially. ## Post Process Actions Post process actions can be specified. The supported actions are: - `onerrorfail`: fail on the first error during data retrieval or storage (default). - `onerrorcontinue`: operation continues in `onerrorcontinue` mode on errors. - `extractzip`: consider the document to be a ZIP archive and extract it to a subfolder of the output folder named after the ZIP file name. # Examples To export the mails sent using the mail driver use: ```sql select * except attachment1Contents, attachment2Contents from smtp@mail local export results as "${ATTACHMENT_FOLDER}${system:directoryseparator}email-results.xlsx" format xlsx ```