Function to send Email (ASP.Net)

 If you want to send email using ASP.Net or VB.Net, you can use the function like function below.

-------------- Function-----------------------------
  Public Shared Function SendEmail(ByVal strFrom As String, ByVal strSubject As String, ByVal strAddressTo As String, ByVal strAddressCC As String, ByVal strAddressBCC As String, ByVal strBodyMessage As String) As Boolean
        Dim EmailMessage As New MailMessage
        Dim EmailClient As New SmtpClient(SMTPServer)

        Try
            EmailMessage.Subject = strSubject
            EmailMessage.From = strFrom

            EmailMessage.To.Add(strAddressTo)
            EmailMessage.CC.Add(strAddressCC)
            EmailMessage.Bcc.Add(strAddressBCC )
            EmailMessage.Body = strBodyMessage
            EmailMessage.IsBodyHtml = True
            EmailClient.Send(EmailMessage)

            Return True
        Catch ex As Exception
            Throw
        End Try
    End Function

Comments

Popular posts from this blog

karimun ganti alternator 70A

FOUR Productivity FEYNMAN- strategies

Format Date SQL Server