Log In

This guide helps to set up SMTP2GO with .NET. This library provides a simple way to send email via the SMTP2GO API and also access other endpoints in the API in a standard way.

Advanced setup options, including setting your preferred IOC API connection and using Email Template features, can be found at the GitHub repository.

Step 1

Add a reference to the latest Nuget package:

dotnet add package Smtp2Go.ApiClient

or

Install-Package Smtp2Go.ApiClient

Step 2

Create an Smtp2GoApiService providing your Smtp2Go API key:

var service = new Smtp2GoApiService("api-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

Step 3

Create an EmailMessage object to send

var message = new EmailMessage("From Name ", "To Name ", "alsoto@address.email");

message.BodyHtml = "Email HTML Body";
message.BodyText = "Email Plain Text Body";

message.AddToAddress("anotherto@address.email", "Another To Name");
message.AddCcAddress("ccto@address.email", "Cc To Name");
message.AddBccAddress("bccto@address.email");

Step 4

Optional: add base64 encoded or local file system file attachments to the email:

message.AddAttachment("attachment_name.txt", "base64_attachment_data", "text/plain");
message.AddAttachment("C:\\a_word_document.docx", "application/msword");

Step 5

Optional: add base64 encoded or local file system file inline images to the email:

message.AddInlineImage("image_name.png", "base64_inline_image_data", "image/png");
message.AddInlineImage("C:\\image_file.png", "image/png");

Step 6

Optional: add custom email headers:

message.AddCustomHeader("Reply-To", "Reply To Name ");

Step 7

Send the email using the API service’s async SendEmail method. Response information will contain success and failure information along with any other identifiers returned from the Smpt2Go API.

var response = await service.SendEmail(message);

Integrating SMTP2GO and .NET should be an easy, quick and, hopefully, painless process. And going forward your email delivery should be outstanding!

You can access reports directly in your SMTP2GO dashboard, which will help you understand delivery successes and failures, tracking information and many more useful metrics. We’ve written some great articles outlining the features of your SMTP2GO account and we recommend taking the time to see everything we have to offer.

Should you need extra help from our award-winning support team, we are almost always available to assist. You can find support contact details in your SMTP2GO dashboard and information about retrieving your support PIN here.

Ready for better email delivery?

Try SMTP2GO free for as long as you like:

Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.