Building applications in .NET is fun and productive but what do you do when you need to add email integrations or test using disposable email accounts? MailSlurp's free DotNET SDK client on nuget lets you create real inboxes on demand for sending and receiving emails in C#, F# and more.

Installing the latest .NET core 6

DotNET was never known for simple naming conventions. Microsoft's open source .NET 6 aims to fix some of the confusing while adding many new performance upgrades and features. To install on Linux 21.04 run:

The use aptitude to install the sdk:

Then install the runtimes:

If you encounter errors about missing packages you may need to purge your dpkg packages

Running should now display version 6.

Starting a new dotnet core project

To scaffold a new application that we can add disposable email accounts to use the dotnet command in the CLI.

This will create a new folder with a structure like so:

Add MailSlurp dependencies to DotNET project

You can add disposable email accounts to your .NET core project easily using the dotnet CLI:

Our csproj file will be updated to include our dependency and look something like this:

Make sure you create a free MailSlurp account to obtain a free API_KEY. We will need that for the next steps.

Configure MailSlurp client for email creating

To configure inboxes import the MailSlurp dependency in your file and configure it like below:

Using disposable email accounts in dotnet to send and receive emails

Now you are probably wondering - how do I use these email addresses? Well with MailSlurp you can create email inboxes and then send and receive emails from them using any email provider, the online dashboard, or in code.

Creating an email address

First step, create an inbox for your test:

Send an email in C Sharp

Sending emails with MailSlurp is simple:

Receive emails

You can receive emails in .NET using MailSlurp too:

Notice the usage. This is a unique feature of MailSlurp that enables you to block the execution and wait for the email you sent to arrive. This is important to avoid race conditions.