Knowledgebase

How to send email from your asp.net code?

' Visual Basic Sample - Sending SMTP Authenticated E-mail

' Please replace yourdomain.com in code with your domain hosted with us
'
Private Sub SendEmail()
Try
' Create a new MailMessage object and specify the "From" and "To" addresses
Dim message As New MailMessage("From email", "To Email", "Subject", "Body message")
Dim emailClient As New SmtpClient("mail.yourdomain.com") 
' Authentication
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("User@yourdomain.com", "Password")
emailClient.UseDefaultCredentials = False
emailClient.Credentials = basicAuthenticationInfo
message.IsBodyHtml = True
emailClient.Send(message)
Catch ex As Exception
MessageBox.Show("Error sending email: " + ControlChars.NewLine _
+ ControlChars.NewLine + ex.Message)
End Try
End Sub

 

----------------------------------------------------------------------

 

 

Web.config

<system.net>

<mailSettings>

<smtp>

<network host="mail.yourdomain.com" port="8889" userName="yourmail@yourdomain.com" password="password" />

</smtp>

</mailSettings>

</system.net>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Was this answer helpful?

 Print this Article

Also Read

Login URL for the Web Site Panel

For shared hosting - https://wsp.aspnethosting.co.uk

MS SQL 2008 and MySQL server addresses

MSSQL 2008 server addresses are: sql2008.aspnethosting.co.uk sql2008r2.aspnethosting.co.uk...

How to configure web deploy/ webmatrix?

How to configure Web deploy & Webmatrix in WebsitePanel First log in WebsitePanel, navigate...

Understanding Physical and Virtual Directory Structures

Beyond home directory wwwroot, Microsoft Web sites also use the following:■ Physical...

Conection String to MS SQL 2008 DB - example

In order to connect to SQL Server 2008 from Management Studio, Enterprise Manager, Query...