You can send emails with the .NET libraries that come with the framework such as the APIs from the System.Net.Mail namespace. They are suitable for this kind of development, however, sometimes you need a more straightforward and powerful way to generate and send emails.
In this post, you will learn how to generate and send emails using the FluentEmail library connected with Twilio SendGrid in a console project with .NET.
You will need a free Twilio SendGrid account and some experience with the C# language and .NET platform to complete this tutorial. Sign up here to send up to 100 emails per day completely free of charge.
Finally, you will need the following for your development environment:
There are a hundred different ways to provide configuration to your applications. For almost any programming language, you can use environment variables and .env files, but configuration can also be stored in other file formats like JSON, YAML, TOML, XML, INI, and the list keeps on going. Though, in some scenarios configuration isn't pulled from files, but instead is pulled from a service like Azure Key Vault, HashiCorp Vault, or a similar vault service. It is rare that your configuration will come from a single source. Luckily, there are APIs in .NET that can help you grab configuration from multiple sources and merge them together.
In this tutorial, you'll start with an application that sends text messages using Twilio Programmable SMS, where the configuration is fetched directly from the environment variables. You'll then refactor the app to
- fetch configuration from multiple sources, specifically, JSON files, user-secrets, environment variables, and …
The Twilio helper library for ASP.NET (Twilio.AspNet) is a community-driven open-source project to make integrating Twilio with ASP.NET easier, for both ASP.NET Core and ASP.NET MVC on .NET Framework. The library helps you with very common use cases like:
- Responding to Twilio webhook requests with TwiML objects from the official Twilio SDK for C# and .NET.
- Binding data from Twilio webhook requests to strongly typed .NET objects.
- Validating webhook requests originate from Twilio and rejecting them if not.
As .NET and ASP.NET is evolving, the Twilio.AspNet contributors are enhancing the library to take advantage of the newest capabilities and best practices. So what's new?
What's old in Twilio.AspNet
Actually, before I share the shiny new additions, let me share what is already part of the library. After all, this is the first blog post to share news about the library.
Handle Twilio webhook requests with ASP.NET
In previous versions …
You can quickly buy a phone number using Twilio's Super Network and then use that phone number to send and receive SMS. However, not all applications require two-way messaging. What's more, there are a lot of use cases where one-way messaging is a better fit, for example: notifications, alerts, and verifications. For these kinds of scenarios, you should consider using an Alphanumeric Sender ID.
In this tutorial, you will learn how to send SMS messages from an Alphanumeric Sender ID with C#, .NET, and Twilio Programmable SMS; but first...
What is an Alphanumeric Sender ID
An Alphanumeric Sender ID (or Alpha Sender) lets you send SMS messages from a sender ID that consists of a set of alphanumeric characters, instead of from a phone number.
The biggest benefit of using Alpha Sender is that you can use an ID that is more recognizable to your users than a …
また、SMTPを基盤とする既存のコードベースがある場合は、SMTPプロトコルを使用することもできます。本稿では、SendGrid .NET SDKと.NET 6コンソールアプリケーションを使用してメールを送信する方法をご紹介します。
- .NET 6 SDK(ダウンロード)
- コードエディタまたはIDE(推奨: C#プラグインを導入したVS Code、Visual Studio、JetBrains Rider)
- Twilio SendGridのアカウント(登録はこちらから)
1つ目は、Sender Authentication(送信者の認証)の設定です。送信者の認証は、送信者がメールを送信するメールアドレスまたはドメインを所有していることを確 …
At times, people in many organizations must organize and associate files (such as accounts, invoices, and more) with each employee or vendor in the company. Generally, these files arrive by email to a default mailbox that is constantly monitored, but manually. In this post, you are going to learn how to organize and associate files that users send by email to a particular mailbox through Twilio SendGrid with an API built in ASP.NET.
To complete this tutorial, you will need a free Twilio SendGrid account and experience working with ASP.NET applications using the C# language. Sign up here to send up to 100 emails per day completely free of charge.
Additionally, the API that you are going to create needs to be publicly exposed to be accessed from Twilio SendGrid, in this tutorial you will use ngrok to test your application without the need to deploy it in …
Every few years, the Open Web Application Security Project (OWASP) publishes a new list of the 10 most common security issues in web applications, called OWASP Top 10. There is one security flaw that has been around since the first edition in 2003, and grabbed the first spot in the 2010, 2013, and 2017 editions, and that security issue is vulnerability to injection attacks. I previously talked about injection attacks in general and more specifically, how dangerous email HTML injection attacks are and how you can prevent them. However, in this post, you'll learn how you can mitigate HTML injection attacks in .NET specifically.
How HTML injection into emails work
HTML injection is a vulnerability where an application accepts user input and then embeds the input into HTML. A malicious user can inject HTML through the user input so that their malicious HTML is embedded into …
As part of ASP.NET Identity, ASP.NET Core provides a bunch of features for account management, authentication, and authorization. ASP.NET Identity also sends emails to confirm email addresses and reset passwords, but it's up to you to implement how those emails are sent.
In this tutorial, you will learn how to send ASP.NET Identity emails using Twilio SendGrid.
You will need these things to follow along:
- An OS that supports .NET (Windows/macOS/Linux)
- .NET 6 SDK
- A code editor or IDE (I recommend VS Code with the C# plugin, Visual Studio, or JetBrains Rider)
- A Twilio SendGrid account. Sign up here to send up to 100 emails per day completely free of charge.
Configure your SendGrid account …
Telehealth services can improve access to healthcare for people living in remote areas. One common issue in remote areas is unreliable internet service. It’s a challenge for patients in remote areas to make appointments via web applications when internet service is poor or not available at all.
SMS is a reliable and low-cost alternative to reach people living in remote areas. In this article, you will learn how to build a doctor appointment booking system which allows users to book via SMS.
The architecture of the SMS booking system is illustrated below.
Twilio is the communication channel between Microsoft Azure Bot Service and the end user. The core of the system is an Azure Bot built on the Microsoft Bot Framework. When the bot receives a message, it asks Language Understanding (LUIS) to analyze the message. LUIS responds with the intent of the message, which the bot …
Email has been around for decades, but sending emails at scale is still hard. With Twilio SendGrid, you can send emails without worrying about scalability. You can use the SendGrid APIs to send emails, but if you're already using SMTP in your code, you can also use the SMTP protocol with SendGrid. In this post, you will learn how to send emails using SMTP, SendGrid, and a .NET 6 console application.
This tutorial is built upon .NET 6, but all code works with older versions of .NET, including .NET Framework with minor adjustments.
You will need the following things to follow along:
- An OS that supports .NET (Windows/macOS/Linux)
- .NET 6 SDK
- A code editor or IDE (Recommended: VS Code with the C# plugin, Visual Studio, or JetBrains Rider)
- A Twilio SendGrid account (Sign up for free)
You can find the source code for …