Sending Simple E-Mail in C#
(Page 1 of 4 )
It’s been decades since carrier pigeons became digitalized and supercharged. Nowadays sending a mail has become synonymous with sending an e-mail, meaning electronic mail, and usually this delivery process takes less than a second. As a result, we're required to send e-mail nearly every day. This article takes a look at how we can accomplish this task in C#.
Thus, this is going to be a tutorial written in the “how-to” fashion. First, we are going to dwell on the basics and I’m going to explain the theory. This is where we’ll talk about frameworks, functions, libraries, and in short about SMTP servers. We'll also discuss what credentials are and why are they important, as well as SSL. Later on, we’re going to develop ready-to-run real-world applicable source code that sends mail.
Throughout this article I’m going to present three solutions to accomplish the task of sending mail using C#. The first will be based on the System.Web.Mail component that is part of the older dot net frameworks (.NET 1.0 and 1.1). If you are coding in those environments then this is going to be useful to you. Next we’ll also present the currently possible solution that is based on the latest .NET frameworks.
Here I’m talking about .NET 2.0 and 3.5 (3.x). We are going to use the following components: System.Net and System.Net.Mail. These are all part of the latest dot net Frameworks. At the end of the article you will be able to download the archived source code of this tiny little application. By this point everything should make sense and you’ll see the difference between the older solution and this one.
Ultimately, as the third solution, we’ll present the commercial component package called Chilkat, specifically their best-selling mail components: Chilkat Mail. We can use its 30-day trial period; that is more than enough time for us to play around and see how it performs, what we can do with it, and so forth. You’ll see a code sample that is based on Chilkat Mail, too. And that's everything in a nutshell.
All of this being said, let’s get started.
Next: Theory >>
More C# Articles
More By Barzan "Tony" Antal