Imports System.Web.Mail Imports System.io Namespace email Partial Class WebForm1 Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here End Sub Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click Dim filelocation, strfilename As String Dim mymail As MailMessage = New MailMessage filelocation = txtFile.PostedFile.FileName mymail.From = txtFrom.Text mymail.To = txtTo.Text mymail.Cc = txtCc.Text mymail.Bcc = txtCc.Text mymail.Subject = txtSubject.Text mymail.Body = txtMessage.Text txtFile.PostedFile.SaveAs(filelocation) mymail.Attachments.Add(New MailAttachment(filelocation)) SmtpMail.SmtpServer = txtSMTPServer.Text Try SmtpMail.Send(mymail) Catch ex As Exception MsgBox("Send failure: " + ex.Message) End Try File.Delete(filelocation + strfilename) End Sub End Class End Namespace