Versuchen GOLD - Frei

Sending Email with SendGrid

CODE Magazine

|

July - August 2025

C# provides several ways to send email. Maybe you've used the SMTPClient class or perhaps you've used the Mailkit NuGet package, which is what Microsoft recommends for new code.

These solutions work well if you need to send a few messages and if you have access to an SMTP server. However, if you need to send lots of messages, you're quickly going to run into things like SPAM filters, daily message send limits and, in the worst case, you might get your domain flagged or blocked.

As a result, many people looking to do bulk email end up using a third-party solution to act as a message broker and send the mail on their behalf. In this article, I'm going to take a look at one of these solutions, SendGrid, which, in my experience, is relatively easy to use, relatively affordable, and which comes with some nice C# utility classes.

Getting Set Up

The first step in using SendGrid is to sign up for a SendGrid account, and SendGrid does provide a free trial. Go to https://sendgrid.​com and click the Start For Free button.

Then, simply follow the sign-up wizard to configure your Twilio account, which gives you access to SendGrid as well as some other Twilio tools.

Once you're logged into SendGrid, you'll land on your SendGrid Dashboard, as shown in Figure 1.

From this dashboard, you can start setting up your prerequisites.

Create an API Key

The SendGrid API is a REST API that is secured with an API key. On the SendGrid Dashboard, expand the Settings item in the sidebar on the left and click the API Keys menu item, as shown in Figure 2. Click the Create API Key button in the upper right corner and walk through the process for generating a new API key Note that when you create a new API Key, SendGrid shows you the actual text of the Key in the confirmation screen, but never again. It's not like Azure Key Vault and other apps where you can click a button to reveal or copy the key value. You need to copy it at this initial step and save it somewhere else or else you'll be forced to create a new key.

Verify a "Single Sender"

CODE Magazine

Diese Geschichte stammt aus der July - August 2025-Ausgabe von CODE Magazine.

Abonnieren Sie Magzter GOLD, um auf Tausende kuratierter Premium-Geschichten und über 9.000 Zeitschriften und Zeitungen zuzugreifen.

Sie sind bereits Abonnent?

WEITERE GESCHICHTEN VON CODE Magazine

CODE Magazine

Identifying and Reducing Test Case Combinatorial Explosions with Python's Abstract Syntax Tree (AST) and Pytest Framework

Test matrix explosions are a growing challenge in modern software testing, especially when using parameterized tests in machine learning pipelines.

time to read

3 mins

July - August 2025

CODE Magazine

CODE Magazine

The New Features and Enhancements in .NET 10 H

By the end of this year, Microsoft plans to release .NET 10 (in November 2025). Incidentally, it will be a Long-Term Support (LTS) release. The preview version of .NET 10 is already available.

time to read

2 mins

July - August 2025

CODE Magazine

Unlocking Angular Performance: Optimization Techniques

Optimizing Angular applications for speed and efficiency requires a deliberate strategy.

time to read

2 mins

July - August 2025

CODE Magazine

Git Branching Strategies

Sometimes when we reach for the stars, we forget to keep our feet on the ground. Whenever I sit down to write these articles, I wonder what I should write about.

time to read

6 mins

July - August 2025

CODE Magazine

Sending Email with SendGrid

C# provides several ways to send email. Maybe you've used the SMTPClient class or perhaps you've used the Mailkit NuGet package, which is what Microsoft recommends for new code.

time to read

4 mins

July - August 2025

CODE Magazine

Natural Language Al-Powered Smart UI

Looking for real-world AI examples is a challenge and part of this challenge comes from Generative AI (GenAI) news dominating the media. It feels like every AI demo involves chatting with GenAl to produce content. The obligatory chat completion demo has started to become the to-do list of AI demo apps, and, to make matters worse, it's selling AI short.

time to read

9 mins

July - August 2025

CODE Magazine

CODE Magazine

Three Conferences, One Destination: MAXIMIZING YOUR AI-ERA LEARNING INVESTMENT

MAXIMIZING YOUR AI-ERA LEARNING INVESTMENT

time to read

4 mins

July - August 2025

CODE Magazine

Exploring .NET MAUI: Popups, Messages, and Data Validation

Through this article series, you've created several .NET MAUI pages, performed navigation, used data binding, and worked with the MVVM and DI design patterns. As you created your view models, you've set information and exception message properties. In this article, you'll build reusable components to display information, error, and validation messages on your pages. To validate

time to read

11 mins

May - June 2025

CODE Magazine

Unlock Serverless Azure Functions

The evolution of cloud computing has transformed how developers build and deploy applications. One of the most significant shifts in this evolution is the rise of serverless architecture. Traditionally, building and maintaining applications requires managing servers, scaling infrastructure, and handling operational concerns.

time to read

10 mins

May - June 2025

CODE Magazine

Securing ASP.NET Core Blazor Applications

Blazor is a modern web framework from Microsoft used for building interactive web applications using C# and .NET. It's based on a flexible, modular component model well suited for building applications with rich, interactive web user interfaces. Blazor leverages the authentication mechanism of ASP.NET Core to establish the identity of a user.

time to read

5 mins

May - June 2025

Listen

Translate

Share

-
+

Change font size