Skip to content

Repository files navigation

MailAlertServer

A SQL Server-based Windows service that monitors database conditions and sends email alert notifications.

Building

Prerequisites

Build

dotnet build

Publish

To publish a self-contained release build:

dotnet publish -c Release

Output will be in bin/Release/net8.0/win-x64/publish/.

Installation

Using the Installer (Recommended)

Prerequisites

Building the Installer

  1. Publish the application:
    dotnet publish -c Release
    
  2. Compile the installer using Inno Setup:
    iscc setup.iss
    
  3. The installer will be created as Output/MailAlertServerSetup.exe.

Running the Installer

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:

  1. Install the application files
  2. Create the database and tables using sqlcmd
  3. Create the SQL Server login and database user for the application
  4. Generate the config.txt configuration file
  5. Register and start the MailAlertServer Windows service

Manual Installation

  1. Publish the application and copy the output to your desired install directory.
  2. Run setup_db.sql against your SQL Server using sqlcmd to create the database, tables, and application user:
    sqlcmd -S localhost -E -v DbName="MailAlertDB" AppUser="mailalert_user" AppPass="YourPassword" -i setup_db.sql
    
  3. Create a config.txt file in the application directory:
    Server=localhost
    Database=MailAlertDB
    Username=mailalert_user
    Password=YourPassword
    Interval=60
    TrustServerCertificate=True
    
  4. Install and start the Windows service:
    sc create MailAlertServer binPath= "C:\Path\To\MailAlertServer.exe" start= auto
    sc start MailAlertServer
    

Configuration

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

Uninstallation

Use the standard Windows Add or Remove Programs to uninstall. The uninstaller will stop and remove the Windows service automatically.

About

Email Alert Service using SQL Queries

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages