A SQL Server-based Windows service that monitors database conditions and sends email alert notifications.
dotnet build
To publish a self-contained release build:
dotnet publish -c Release
Output will be in bin/Release/net8.0/win-x64/publish/.
- Inno Setup (to build the installer)
- sqlcmd (required on the target machine)
- Publish the application:
dotnet publish -c Release - Compile the installer using Inno Setup:
iscc setup.iss - The installer will be created as
Output/MailAlertServerSetup.exe.
The installer will prompt for:
- SQL Server instance — The server name or IP address hosting the database.
- Setup authentication — Windows Authentication or SQL Server Authentication for the admin account used to create the database, tables, and application login.
- Database name — The name of the application database (created if it does not exist).
- Application credentials — The SQL Server login and password that the service will use at runtime (created if they do not exist).
- Check interval — How often (in seconds) the service checks for alert conditions.
The installer will:
- Install the application files
- Create the database and tables using
sqlcmd - Create the SQL Server login and database user for the application
- Generate the
config.txtconfiguration file - Register and start the MailAlertServer Windows service
- Publish the application and copy the output to your desired install directory.
- Run
setup_db.sqlagainst your SQL Server usingsqlcmdto create the database, tables, and application user:sqlcmd -S localhost -E -v DbName="MailAlertDB" AppUser="mailalert_user" AppPass="YourPassword" -i setup_db.sql - Create a
config.txtfile in the application directory:Server=localhost Database=MailAlertDB Username=mailalert_user Password=YourPassword Interval=60 TrustServerCertificate=True - Install and start the Windows service:
sc create MailAlertServer binPath= "C:\Path\To\MailAlertServer.exe" start= auto sc start MailAlertServer
The service reads its configuration from config.txt located in the application directory.
| Setting | Description | Default |
|---|---|---|
| Server | SQL Server instance name or IP address | localhost |
| Database | Database name containing the mail alert tables | MailAlertDB |
| Username | SQL Server login username | dbuser |
| Password | SQL Server login password | dbpassword |
| Interval | Alert check interval in seconds | 60 |
| TrustServerCertificate | Trust the SQL Server certificate without validation | True |
Use the standard Windows Add or Remove Programs to uninstall. The uninstaller will stop and remove the Windows service automatically.