I try to use the following code to send mails but gives me the error :
"A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll"

Imports System
Imports System.Web.Mail

Public Class Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim oMsg As Web.Mail.MailMessage = New Web.Mail.MailMessage()
oMsg.From = "[email protected]"
oMsg.To = "[email protected]"
oMsg.Subject = "Email with Attachment Demo"
oMsg.Body = "This is the main body of the email"

Try
SmtpMail.SmtpServer = "pop.gmail.com"
SmtpMail.Send(oMsg)
Catch ehttp As System.Web.HttpException
Console.WriteLine("0", ehttp.Message)
Console.WriteLine("Here is the full error message")
Console.Write("0", ehttp.ToString())
End Try

End Sub