PowerBuilder
PowerBuilder
Getting TO / CC Email Recipients
Demonstrates how to examine the TO and CC recipients of an email.Note: BCC recipients are generally NOT found in the email's MIME. "BCC" is a "Blind Carbon Copy", which means that the TO and CC recipients of the email should not be able to see the BCC recipients. If the BCC email addresses were found in the MIME header, then they would no longer be "blind" because nothing would prevent the other recipients from seeing the list of BCC recipients.
To understand how BCC recipients receive an email, I recommend reading this blog post: SMTP Protocol in a Nutshell. The BCC recipients are passed to the SMTP server in “RCPT TO” commands.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Email
integer i
integer li_NumTo
integer li_NumCC
li_Success = 0
// An email can have any number of To, CC, or Bcc recipients.
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("sample.eml")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
// It doesn't matter if the email object was loaded from a .eml file,
// or if it was downloaded from a POP3 or IMAP server.
// The methods and properties for examining the TO and CC
// recipients are the same.
// The number of TO recipients is found in the NumTo property
li_NumTo = loo_Email.NumTo
// Iterate over each TO recipient
if li_NumTo > 0 then
for i = 0 to li_NumTo - 1
Write-Debug "TO Friendly Name and Address: " + loo_Email.GetTo(i)
Write-Debug "TO Address: " + loo_Email.GetToAddr(i)
Write-Debug "TO Friendly Name: " + loo_Email.GetToName(i)
Write-Debug "---"
next
end if
// The number of CC recipients is found in the NumCC property
li_NumCC = loo_Email.NumCC
// Iterate over each CC recipient
if li_NumCC > 0 then
for i = 0 to li_NumCC - 1
Write-Debug "CC Friendly Name and Address: " + loo_Email.GetCC(i)
Write-Debug "CC Address: " + loo_Email.GetCcAddr(i)
Write-Debug "CC Friendly Name: " + loo_Email.GetCcName(i)
Write-Debug "---"
next
end if
destroy loo_Email