Importing Email Attachments with gsqlcmd
gsqlcmd includes the GetAttachments utility that allows saving email attachments into a local folder.
Then you can import data from the saved attachments using gsqlcmd.
gsqlcmd allows getting data from XML, JSON, CSV, HTML, Excel and plain text files.
Also, gsqlcmd automatically extracts files from the zip and gzip archives.
To get the GetAttachments short help, run:
GetAttachments.exe help
To configure the tool, run:
GetAttachments.exe init
The tool creates the default configuration file 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 command:
GetAttachments.exe [<configuration file>]
Configuration File Format
GetAttachments.cfg is a CSV file with the following required fields:
Field | Description |
---|---|
Active | true | false |
Protocol | POP3 | IMAP |
Server | POP3 or IMAP server |
Login | Login |
Password | Password |
Port | Port |
UseSSL | true | false |
Delete | true | false |
Mask | A file mask to save attachments like \*.gz,\*.xls* |
AttachmentFolder | The folder to save attachments |
ArchiveFolder | The folder of the processed attachments |
You can move the processed attachments from the AttachmentFolder to the ArchiveFolder folder.
The tool checks the ArchiveFolder folder to prevent saving processed files into the AttachmentFolder folder in the next cycles.