PowerBuilder Requires Chilkat v11.0.0+
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Email
oleobject loo_Mail
li_Success = 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
destroy loo_Email
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Email.LoadEml("with-attachments.eml")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
// Enable this option before adding a blind recipient to the message.
loo_Email.UncommonOptions = "NoBccHeader"
li_Success = loo_Email.AddBcc("Bcc recipient","bcc@example.net")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
loo_Mail = create oleobject
li_rc = loo_Mail.ConnectToNewObject("Chilkat.MailMan")
loo_Mail.SmtpHost = "smtp.example.com"
loo_Mail.SmtpPort = 465
loo_Mail.SmtpSsl = 1
loo_Mail.RequireSslCertVerify = 1
loo_Mail.SmtpUsername = "MAIL_USER"
loo_Mail.SmtpPassword = "MAIL_PASSWORD"
li_Success = loo_Mail.SendEmail(loo_Email)
if li_Success <> 1 then
Write-Debug loo_Mail.LastErrorText
destroy loo_Email
destroy loo_Mail
return
end if
Write-Debug "The SMTP relay accepted the message."
li_Success = loo_Mail.CloseSmtpConnection()
if li_Success <> 1 then
Write-Debug loo_Mail.LastErrorText
destroy loo_Email
destroy loo_Mail
return
end if
destroy loo_Email
destroy loo_Mail