C# Documentation

Create test email accounts in DotNET and Csharp. Send and receive emails in Windows applications and tests.

MailSlurp C# Library

NOTE: this libary does not include DLLs and requires that you build them. Some users may find calling the REST API directly a simpler solution.

For full documentation and a list of available SDK clients please see the developer guide. Create an account in the MailSlurp Dashboard to view your API Key. For all bugs, feature requests, or help please see support.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 0.0.1-alpha
  • SDK version: 5.2.1
  • Build package: org.openapitools.codegen.languages.CSharpRefactorClientCodegen For more information, please visit https://www.mailslurp.com

Frameworks supported

  • .NET Core >=1.0
  • .NET Framework >=4.6
  • Mono/Xamarin >=vNext
  • UWP >=10.0


  • FubarCoder.RestSharp.Portable.Core >=4.0.7
  • FubarCoder.RestSharp.Portable.HttpClient >=4.0.7
  • Newtonsoft.Json >=10.0.3


Generate the DLL using your preferred tool

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using mailslurp.Api;
using mailslurp.Client;
using mailslurp.Model;

Getting Started

using System;
using System.Diagnostics;
using mailslurp.Api;
using mailslurp.Client;
using mailslurp.Model;

namespace Example
    public class Example
        public void main()

            // Configure API key authorization: API_KEY
            Configuration.Default.ApiKey.Add("x-api-key", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // Configuration.Default.ApiKeyPrefix.Add("x-api-key", "Bearer");

            var apiInstance = new CommonOperationsApi();

                // Create new email address
                Inbox result = apiInstance.CreateNewEmailAddress();
            catch (Exception e)
                Debug.Print("Exception when calling CommonOperationsApi.CreateNewEmailAddress: " + e.Message );


Documentation for API Endpoints

All URIs are relative to https://api.mailslurp.com

Class Method HTTP request Description
CommonOperationsApi CreateNewEmailAddress POST /newEmailAddress Create new email address
CommonOperationsApi DeleteEmail DELETE /deleteEmail Delete an email
CommonOperationsApi DeleteEmailAddress DELETE /deleteEmailAddress Delete email address and its emails
CommonOperationsApi EmptyInbox DELETE /emptyInbox Delete all emails in an inbox
CommonOperationsApi SendEmailSimple POST /sendEmail Send an email from a random email address
CommonOperationsApi WaitForEmailCount GET /waitForEmailCount Wait for and return count number of emails
CommonOperationsApi WaitForLatestEmail GET /waitForLatestEmail Fetch inbox's latest email or if empty wait for email to arrive
CommonOperationsApi WaitForMatchingEmail POST /waitForMatchingEmails Wait or return list of emails that match simple matching patterns
CommonOperationsApi WaitForNthEmail GET /waitForNthEmail Wait for or fetch the email with a given index in the inbox specified
ExtraOperationsApi BulkCreateInboxes POST /bulk/inboxes Bulk create Inboxes (email addresses)
ExtraOperationsApi BulkDeleteInboxes DELETE /bulk/inboxes Bulk Delete Inboxes
ExtraOperationsApi BulkSendEmails POST /bulk/send Bulk Send Emails
ExtraOperationsApi CreateDomain POST /domains Create Domain
ExtraOperationsApi CreateInbox POST /inboxes Create an Inbox (email address)
ExtraOperationsApi CreateWebhook POST /inboxes/{inboxId}/webhooks Attach a WebHook URL to an inbox
ExtraOperationsApi DeleteDomain DELETE /domains/{id} Delete a domain
ExtraOperationsApi DeleteEmail1 DELETE /emails/{emailId} Delete Email
ExtraOperationsApi DeleteInbox DELETE /inboxes/{inboxId} Delete Inbox / Email Address
ExtraOperationsApi DeleteWebhook DELETE /inboxes/{inboxId}/webhooks/{webhookId} Delete and disable a WebHook for an Inbox
ExtraOperationsApi DownloadAttachment GET /emails/{emailId}/attachments/{attachmentId} Get email attachment
ExtraOperationsApi ForwardEmail POST /emails/{emailId}/forward Forward Email
ExtraOperationsApi GetDomain GET /domains/{id} Get a domain
ExtraOperationsApi GetDomains GET /domains Get domains
ExtraOperationsApi GetEmail GET /emails/{emailId} Get Email Content
ExtraOperationsApi GetEmails GET /inboxes/{inboxId}/emails List Emails in an Inbox / EmailAddress
ExtraOperationsApi GetEmailsPaginated GET /emails Get all emails
ExtraOperationsApi GetInbox GET /inboxes/{inboxId} Get Inbox / EmailAddress
ExtraOperationsApi GetInboxes GET /inboxes List Inboxes / Email Addresses
ExtraOperationsApi GetRawEmailContents GET /emails/{emailId}/raw Get Raw Email Content
ExtraOperationsApi GetWebhooks GET /inboxes/{inboxId}/webhooks Get all WebHooks for an Inbox
ExtraOperationsApi SendEmail POST /inboxes/{inboxId} Send Email
ExtraOperationsApi UploadAttachment POST /attachments Upload an attachment for sending
ExtraOperationsApi UploadMultipartForm POST /attachments/multipart Upload an attachment for sending using Multipart Form

Documentation for Models

Documentation for Authorization


  • Type: API key
  • API key parameter name: x-api-key
  • Location: HTTP header