Email notification is a common part of most applications. The System.Web.Mail namespace can be used to send HTML mails and even add attachments to it.
We will create a console-based application to demonstrate the same.
Here is the code for the console application (HTMLMail.cs)
We create a Mail object and set the appropriate mail properties like To, From, CC, Subject, and Body and then set the BodyFormat property of the mail object to HTML.
Let's see how do we add an attachment to the above mail. Add the command given below just before we send the mail with the statement Smtp.Send .
Compile the above code using the following command
csc /r:System.Web.dll HTMLMail.cs
You can run the console.exe from command prompt to send the mail. Happy Coding !!!!