Send E-mail for Free with ASP.Net, VB.Net, C# and other .Net Applications

38741 Users read it.
by John Alessi (May 7, 2003)

Learn the basics of sending e-mail with .Net.  Discusses the issues pertaining to the needs of most developers and explains them in an easy to understand way.  Learn how to start sending e-mail from your .Net apps right away.  Includes sample code that can be downloaded.  You can be sending e-mail like a pro in minutes.

User Rating (68 votes)
0 reviews available
Author(s):John Alessi, Quiksoft Corporation
User Level:Beginner
Language:C#, VB.NET
Platform:Windows

Sending E-mail with .Net, the Easy Way

You can send robust e-mail messages from your .Net app within minutes...

In this edition of E-mail Secrets you will learn the basics of sending e-mail with .Net. We will take a look at the issues pertaining to the needs of most developers and explain them in an easy to understand way. We will try to stay away from complicated topics such as MIME, Base64, etc... Most of the software that we will use to send the messages is free and shields the developer from a learning curve. Most importantly, we will show you how to start sending e-mail from your .Net apps right away. The included sample code can be downloaded and you can be sending e-mail like a pro in minutes... Read on...

In this edition you will learn:

  • The basics of sending e-mail
  • How to attach files to your messages
  • How to send an HTML message that contains support for non HTML mail readers
  • Several reasons why the System.Web.Mail classes are not your best bet
  • How to send e-mail through a server that requires authentication
  • How to overcome the #1 problem most developers encounter when trying to send e-mail from their application

This edition also contains sample code that will enable you to:

  • Create and send an e-mail message with only one line of code
  • Create and send a message containing an attachment
  • Create and send an HTML e-mail message with text support for non HTML readers
  • Send a message through a server that requires authentication
  • Specify backup servers for your outgoing message

Do you really want to look under the hood?...

Sending e-mail is either incredibly complicated, or a very simple task. It all depends on your perspective. Every day we get into our cars and drive from here to there, mostly not worrying about the mechanics under the hood. E-mail is similar. Users of popular e-mail software can send an e-mail message without having to worry about the low level details such as RFC-822, MIME, Base64, etc...

Developers of e-mail applications often find themselves wrestling with these details, but that does not have to be so. With the advent of several excellent developer tools (assemblies in .Net speak), any developer with even trivial .Net experience can send e-mail like the pros without worrying about the complexities "under the hood."

I am not going to dwell on these complexities, because I don't believe that you need to understand them to build a successful e-mail enabled application. If you appreciate the finer details of the process, there are plenty of RFC's on the Internet which you can spend countless hours deciphering. Suffice it to say that I have done that so you don't have to. For those who want to build dependable applications that send e-mail, without investing in a large learning curve, read on...

The very basics...

Even though I promised not to waste your time and/or bore you with the low level details, I want to give you a basic primer on e-mail technology because I think that it will help you ground yourself and enable you to relate what I have to say in this article with other things you may read.

E-mail is delivered across the Internet with the SMTP protocol. The SMTP protocol dictates how e-mail messages are submitted to the Internet and delivered to the recipient. The construct of each message is governed by many other specifications. The specifications for SMTP and the construct of messages are contained in the multitude of RFC's floating around the Internet.

Without diving into all the internals, I want you to know that the code in this newsletter will enable you to build messages that take advantage of all the latest e-mail technologies while preserving compatibility across the different mail servers and readers on the net.

Enough said, lets get on with it.

The following sample will show you how to send e-mail from your .Net applications with only one line of code...

The absolutely easiest and fastest way to send email...

This one line of code will create and send an e-mail message. It uses the FreeSMTP.Net assembly, which can be downloaded here. More on FreeSMTP.Net in a minute...

VB Sample

Quiksoft.FreeSMTP.SMTP.QuickSend( _
"mail.yourdomain.com", _
"recipient@domain.com", _
"sender@domain.com", _
"Subject...", _
"Message text.", _
Quiksoft.FreeSMTP.BodyPartFormat.Plain)

C# Sample

Quiksoft.FreeSMTP.SMTP.QuickSend(
"mail.yourdomain.com",
"recipient@domain.com",
"sender@domain.com",
"Subject...",
"Message text.",
Quiksoft.FreeSMTP.BodyPartFormat.Plain);

It doesn't get much easier than this. Add a reference to the FreeSMTP.Net assembly, and call the QuickSend method. Because the QuickSend() method is static, you do not even have to instantiate a class. The method will even allow the sending of HTML messages, by setting the last parameter to BodyPartFormat.HTML.

FreeSMTP.Net is free as its name implies. But don't think that because it is free, that it is not good. FreeSMTP.Net is produced by Quiksoft who also produces the popular EasyMail Objects, EasyMail Advanced API and EasyMail .Net Edition. Quiksoft specializes in e-mail technologies for professional developers. FreeSMTP.Net is offered by Quiksoft as an introduction to its product line. It is not often that you find quality in things for free, but FreeSMTP.Net is clearly an exception.

John Alessi

John Alessi has specialized in e-mail development for the past 6 years and has helped many large companies such as Microsoft, Boeing and EarthLink with their e-mail needs.

See All Postings From John Alessi >>

Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency