PureBasic Requires Chilkat v11.0.0+
PureBasic
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 PureBasic Downloads
IncludeFile "CkEmail.pb"
IncludeFile "CkMailMan.pb"
Procedure ChilkatExample()
success.i = 0
; Assumes Chilkat is unlocked. See Global Unlock Sample.
email.i = CkEmail::ckCreate()
If email.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkEmail::ckLoadEml(email,"with-attachments.eml")
If success <> 1
Debug CkEmail::ckLastErrorText(email)
CkEmail::ckDispose(email)
ProcedureReturn
EndIf
; Enable this option before adding a blind recipient to the message.
CkEmail::setCkUncommonOptions(email, "NoBccHeader")
success = CkEmail::ckAddBcc(email,"Bcc recipient","bcc@example.net")
If success <> 1
Debug CkEmail::ckLastErrorText(email)
CkEmail::ckDispose(email)
ProcedureReturn
EndIf
mail.i = CkMailMan::ckCreate()
If mail.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkMailMan::setCkSmtpHost(mail, "smtp.example.com")
CkMailMan::setCkSmtpPort(mail, 465)
CkMailMan::setCkSmtpSsl(mail, 1)
CkMailMan::setCkRequireSslCertVerify(mail, 1)
CkMailMan::setCkSmtpUsername(mail, "MAIL_USER")
CkMailMan::setCkSmtpPassword(mail, "MAIL_PASSWORD")
success = CkMailMan::ckSendEmail(mail,email)
If success <> 1
Debug CkMailMan::ckLastErrorText(mail)
CkEmail::ckDispose(email)
CkMailMan::ckDispose(mail)
ProcedureReturn
EndIf
Debug "The SMTP relay accepted the message."
success = CkMailMan::ckCloseSmtpConnection(mail)
If success <> 1
Debug CkMailMan::ckLastErrorText(mail)
CkEmail::ckDispose(email)
CkMailMan::ckDispose(mail)
ProcedureReturn
EndIf
CkEmail::ckDispose(email)
CkMailMan::ckDispose(mail)
ProcedureReturn
EndProcedure