Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending email using vb.net with CC and BCC

Tags:

email

vb.net

smtp

This is a code snippet for sending email using vb.net:

Imports System.Net.Mail
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim SmtpServer As New SmtpClient()
            Dim mail As New MailMessage()
            SmtpServer.Credentials = New _
        Net.NetworkCredential("[email protected]", "password")
            SmtpServer.Port = 587
            SmtpServer.Host = "smtp.gmail.com"
            mail = New MailMessage()
            mail.From = New MailAddress("[email protected]")
            mail.To.Add("TOADDRESS")
            mail.Subject = "Test Mail"
            mail.Body = "This is for testing SMTP mail from GMAIL"
            SmtpServer.Send(mail)
            MsgBox("mail send")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class

Can I add CC and BCC address too? If yes, what are the possible codes?

like image 506
Udhaya Avatar asked Dec 29 '25 07:12

Udhaya


1 Answers

e_mail.CC.Add("[email protected]")
e_mail.Bcc.Add("[email protected]")

Got it from myself :)

like image 88
Udhaya Avatar answered Dec 30 '25 22:12

Udhaya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!