# VBForums CodeBank > CodeBank - ASP / ASP.NET / MVC / Web API >  Sending email via a local email relay or local email server.

## met0555

Sending email via a local email relay or local email server. 

Works on ASP.NET 2.0 and 3.5


asp Code:
Imports System.NetImports System.Net.Mail Dim loginInfo As New NetworkCredential("yourUserName", "yourPassword")Dim msg As New MailMessage(EmailFromTextBox.Text, EmailToTextBox.Text, EmailSubjectTextBox.Text, EmailBodyTextBox.Text)msg.IsBodyHtml = TrueStatusLabel.Visible = False Try    Dim client As New SmtpClient("smtpserver", 25)    client.Credentials = loginInfo    client.Send(msg)Catch ex As SmtpException    StatusLabel.Visible = True    StatusLabel.Style.Add("color", "#CC0033")    StatusLabel.Text = "The following error occurred: " + "<br /><br />" + ex.Message    ReturnEnd Try     StatusLabel.Visible = True    StatusLabel.Style.Add("color", "#009966")    StatusLabel.Text = "Email sent successfully."

----------

