This tutorial will show you how to send a simple email message with an attachment using ASP.NET 2.0 and C#

Sending a email with an attachment using ASP.NET 2.0 and VB.NET is actually very simple.

First, you will need to import the System.Net.Mail namespace.

The System.Net.Mail namespace contains the SmtpClient and MailMessage Classes that we need in order to send the email and the message attachment.

We use the btnSubmit_Click event to do the work.

We then call the emailClient.Send to send the message using the variables from our ASP.NET coded page.

The txtAttachmentPath.Text Texbox provides the path to the file to attach to the email message.

The front end .aspx page looks something like this:

The flow for the code behind page is as follows.