Sample code for 30+ languages & platforms
Java Requires Chilkat v11.0.0+

Send an email with a Bcc recipient using SMTP (live send)

See more Email Object Examples

Live send. Load the previously prepared with-attachments.eml, add a Bcc recipient, and pass the Email to MailMan.SendEmail. For a real test, use a relay you control, replace the sample sender and recipients (including the Bcc address) with test mailboxes, and obtain credentials from your application’s secret store.

Chilkat Java Downloads

Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Email;
import com.chilkatsoft.chilkat2.MailMan;

public class ChilkatExample {

    public static void main(String[] args) {
        // Assumes Chilkat is unlocked. See Global Unlock Sample.

        Email email = new Email();
        try {
            email.loadEml("with-attachments.eml");

            // Enable this option before adding a blind recipient to the message.
            email.setUncommonOptions("NoBccHeader");
            email.addBcc("Bcc recipient", "bcc@example.net");
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        MailMan mail = new MailMan();
        mail.setSmtpHost("smtp.example.com");
        mail.setSmtpPort(465);
        mail.setSmtpSsl(true);
        mail.setRequireSslCertVerify(true);
        mail.setSmtpUsername("MAIL_USER");
        mail.setSmtpPassword("MAIL_PASSWORD");
        try {
            mail.sendEmail(email);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println("The SMTP relay accepted the message.");
        try {
            mail.closeSmtpConnection();
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }
    }
}