I guess, we all are habituated with E-Mails. Sometimes we need to transfer more information in E-Mails so we attach files, presentations, images etc. and when we need it to be more attractive and colorful then we try our hand with Html for making more colorful and attractive and insert images as necessary to make it more meaningful.
When we need to build this type of actions in our application, then we search for related Components and Libraries to get support from. So let's discuss about .Net supported libraries to achieve this type of action in our application. In this article we will cover the System.Net.Mail Namespace of System.dll in .Net Framework 2.0 to build a mailing application.
A simple Html mail:
Let's check a mail message created by System.Net.Mail.MailMessage to send a mail...
The codes are:
Sample for Html mail:
Public Sub SendHtmlMail()
'create the mail message
Dim mail As New MailMessage("firstname.lastname@example.org", "email@example.com")
'set the message content
mail.Subject = "This mail has Html Body.."
mail.Body = "This is a sample body with html in it. This is bold This is blue"
mail.IsBodyHtml = True
End Sub ' End SendHtmlMail
Private Sub SendMail(ByVal mail As Mail.MailMessage)
'send the message using SMTP client
Dim smtp As New SmtpClient(_mailServer) 'mail Server IP or NAME
smtp.Credentials = CredentialCache.DefaultNetworkCredentials
End Sub ' End SendMail
Here "mail" is the instance of MailMessage Class. There are four overloaded constructors available initializing different properties of MailMessage Class during making instance.........
For more details please visit : http://aspalliance.com/1354_Sending_HTML_Mail_with_Embedded_Image_in_NET