Sending a Message with an Attachment Sample Code The following sample code contains a C#-based Windows Console application that shows how to send an e-mail message that includes an attachment. This is done by creating instances of the MessageAttachment class and then adding them to the message through the Attachments collection.
using System; using System.Web.Mail;
namespace CodeGuru.SendMail { /// <summary> /// console application to demonstrate sending e-mail with an /// attachment. /// </summary> class TestMail { /// <summary> /// The main entry point for the application. /// </summary>