Importing Email Attachments with gsqlcmd

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:

FieldDescription
Activetrue | false
ProtocolPOP3 | IMAP
ServerPOP3 or IMAP server
LoginLogin
PasswordPassword
PortPort
UseSSLtrue | false
Deletetrue | false
MaskA file mask to save attachments like \*.gz,\*.xls*
AttachmentFolderThe folder to save attachments
ArchiveFolderThe 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.