Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
ASP.NET: Send an email
From Wiki
Summary: A simple function to send an email
- Public Sub sendEmail(ByVal EmailAddress As String, ByVal Subject As String, ByVal EmailBody As String, ByVal FromAddress As String)
- Dim Message As New MailMessage(FromAddress, EmailAddress, Subject, EmailBody)
- Dim smtp As New SmtpClient("127.0.0.1")
- Dim NetworkCredentials As New System.Net.NetworkCredential
- ' If you are in a development environment without an SMTP server, you can use
- ' the two lines below to send the email to a file
- ' smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
- ' smtp.PickupDirectoryLocation = "c:\emails"
- NetworkCredentials.UserName = "example"
- NetworkCredentials.Password = "example"
- smtp.Credentials = NetworkCredentials
- smtp.Send(Message)
- End Sub
NOTE: Remember to add "Imports System.Net.Mail" to your page/class.
This Hack is part of the ASP.NET Hacks collection



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.