SecretSanta 0.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global SecretSanta --version 0.0.3
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local SecretSanta --version 0.0.3
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=SecretSanta&version=0.0.3
nuke :add-package SecretSanta --version 0.0.3

The Secret Santa App

This was the result of an evening needing distraction and trying to work out when everyone would be in the office to do the Secret Santa hat pick.

It's a simple console application which reads in a list of participants with names and email addresses, randomly assigns a recipient to each secret santa and then emails each secret santa to let them know who they're buying a gift for.

For each secret santa the app creates a pool of recipients, this pool is made up of everyone in the list with the those who have already been picked and the secret santa themselves being removed, the list is then shuffled to ensure that the order of names in the CSV does not influence the result. If at the end of the process the app is left in a position where a person would pick themselves then the process is restarted and repeats until everyone has a recipient assigned to them.

Once all secret santas have a recipient then an email message is generated, using the template defined in the configuration file, and sent to each santa. No record of the process is written locally to prevent the person running the application knowing who is assigned to whom.

Installing the application

The application can be installed on the command line as follows.

C:\> dotnet tool install -g SecretSanta

Running the application

The command line application is executed as follows, note that the help information can be displayed at any time using the command is illustrated below.

C:\> SecretSant -h

Usage - SecretSanta -options

GlobalOption        Description
Help (-h)           Displays the help information
SmtpServer (-s)     The address of the SMTP server with optional port (e.g. smtp.mailtrap.io:465), default port is 465
SmtpUsername (-u)   User for the SMTP server
SmtpPassword (-p)   Password for the SMTP server
FromAddress (-f)    The email address of the sender
InputPath (-i)      Path to the input CSV file containing participants and their email addresses
MessagePath (-m)    Path to the message HTML file

The application will check to see if the files specified exists before running.

An example run would look as follows.

C:\> SecretSanta -s "smtp.mailtrap.io:2525" -u <username> -p <password> -f "secretsanta@example.com" -m message.html -i test.csv

Email message

An exmaple email message is stored in content/message.html. The content of the file is HTML which accepts a placeholder for the recipient name. The placeholder value is {{name}}.

Input CSV

The following is example content for a CSV file. You can create your own with the same structure and column names to run the application.

Name,Email
Robert Banner,rbanner@example.com
Wanda Maximoff,wmaximoff@example.com
Natalia Romanova,nromanova@example.com
Jim Hammond,jhammond@example.com
Carol Danvers,cdanvers@example.com
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.1.0 304 12/26/2021
0.0.3 783 11/29/2018