In this article I will explain with an example, how to send emails with CC and BCC using MailKit using C# and VB.Net.
Installing MailKit package
Sending emails with CC and BCC using MailKit
In order to send emails with CC and BCC, a MimeMessage class object is created.
Then, required properties are set as below:
From – Sender’s email address.
To – Recipient(s) Email Address.
CC – Carbon Copies.
BCC – Blind Carbon Copies.
C#
using (MimeMessage mm = new MimeMessage())
{
//Sender email.
mm.From.Add(new MailboxAddress("Sender", "sender@aspsnippets.com"));
//Recepient Email.
mm.To.Add(new MailboxAddress("Recepient", "recepient@aspsnippets.com"));
//CC Email.
mm.Cc.Add(new MailboxAddress("Cc", "cc@aspsnippets.com"));
//BCC Email.
mm.Bcc.Add(new MailboxAddress("Bcc", "bcc@aspsnippets.com"));
}
VB.Net
Using mm As MimeMessage = New MimeMessage()
'Sender email.
mm.From.Add(New MailboxAddress("Sender", "sender@aspsnippets.com"))
'Recepient Email.
mm.[To].Add(New MailboxAddress("Recepient", "recepient@aspsnippets.com"))
'CC Email.
mm.Cc.Add(New MailboxAddress("Cc", "cc@aspsnippets.com"))
'BCC Email.
mm.Bcc.Add(New MailboxAddress("Bcc", "bcc@aspsnippets.com"))
End Using