Go Requires Chilkat v11.0.0+
Go
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 Go Downloads
success := false
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := chilkat.NewEmail()
success = email.LoadEml("with-attachments.eml")
if success != true {
fmt.Println(email.LastErrorText())
email.DisposeEmail()
return
}
// Enable this option before adding a blind recipient to the message.
email.SetUncommonOptions("NoBccHeader")
success = email.AddBcc("Bcc recipient","bcc@example.net")
if success != true {
fmt.Println(email.LastErrorText())
email.DisposeEmail()
return
}
mail := chilkat.NewMailMan()
mail.SetSmtpHost("smtp.example.com")
mail.SetSmtpPort(465)
mail.SetSmtpSsl(true)
mail.SetRequireSslCertVerify(true)
mail.SetSmtpUsername("MAIL_USER")
mail.SetSmtpPassword("MAIL_PASSWORD")
success = mail.SendEmail(email)
if success != true {
fmt.Println(mail.LastErrorText())
email.DisposeEmail()
mail.DisposeMailMan()
return
}
fmt.Println("The SMTP relay accepted the message.")
success = mail.CloseSmtpConnection()
if success != true {
fmt.Println(mail.LastErrorText())
email.DisposeEmail()
mail.DisposeMailMan()
return
}
email.DisposeEmail()
mail.DisposeMailMan()