Dec
29
2008
Sending eMails within a .Net application is fairly simple with the use of the System.Net.Mail namespace.
First, import the class:
Imports System.Net.Mail
Then create a function to provide for sending the emails within a public class:
Public Shared Function SendEmail(ByVal strFrom As String, _
ByVal strTo As String, _
ByVal strSubject As String, _
ByVal strBody As String) As MailMessage
Dim objReturn As New MailMessage
Try
Dim objMail As New MailMessage(strFrom, strTo)
objMail.Subject = strSubject
objMail.Body = strBody
Dim SmtpMail As SmtpClient = New SmtpClient("smtp.mail.com")
SmtpMail.Send(objMail)
objReturn = objMail
Catch ex As Exception
objReturn = Nothing
End Try
Return objReturn
End Function
The Smtp client will be your local client.
Call this function from anywhere within your application or webpage.