Importing Email Attachments with gsqlcmd
The gsqlcmd
utility includes the GetAttachments
feature, which allows you to save email attachments to a local folder. After saving, you can import data from these attachments using gsqlcmd
.
gsqlcmd
supports data extraction from various formats, including XML, JSON, CSV, HTML, Excel, and plain text files. It also automatically extracts files from ZIP and GZIP archives.
To view the short help for GetAttachments
, run:
GetAttachments.exe help
To set up the tool, execute:
GetAttachments.exe init
This command creates a default configuration file named GetAttachments.cfg
:
Active;Protocol;Server;Login;Password;Port;UseSSL;Delete;Mask;AttachmentFolder;ArchiveFolder false;pop3;mail.domain.com;user@domain.com;password;995;true;false;*.gz,*.xls*;attachments;archive false;imap;imap.domain.com;user@domain.com;password;993;true;false;*.gz,*.xls*;attachments;archive
To run the tool, use the following command:
GetAttachments.exe [<configuration file>]
Configuration File Format
The GetAttachments.cfg
file is a CSV format with the following required fields:
Field | Description |
---|---|
Active | true | false |
Protocol | POP3 | IMAP |
Server | POP3 or IMAP server address |
Login | User login |
Password | User password |
Port | Port number |
UseSSL | true | false |
Delete | true | false |
Mask | File mask for saving attachments (e.g., *.gz, *.xls*) |
AttachmentFolder | Folder to save attachments |
ArchiveFolder | Folder for processed attachments |
You can move processed attachments from the AttachmentFolder to the ArchiveFolder. The tool checks the ArchiveFolder to avoid saving processed files back into the AttachmentFolder during subsequent cycles.