PureBasic
PureBasic
Clear the To Recipients of an Email
See more Email Object Examples
Demonstrates the Chilkat Email.ClearTo method, which clears the list of direct (To) recipients. It changes only the current in-memory email object and does not affect messages already sent. This example adds two To recipients, clears them, and prints the count before and after.
Background: The
To list holds a message's primary recipients. When reusing one Email object as a template across multiple sends, ClearTo wipes just that list so each send addresses the right people, without disturbing the subject, body, or attachments. It pairs with ClearCC and ClearBcc for full control over the recipient lists.Chilkat PureBasic Downloads
IncludeFile "CkEmail.pb"
Procedure ChilkatExample()
; Demonstrates the ClearTo method, which clears the list of direct (To) recipients.
; This changes only the current email object.
email.i = CkEmail::ckCreate()
If email.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkEmail::ckAddTo(email,"Joe","joe@example.com")
CkEmail::ckAddTo(email,"Jane","jane@example.com")
Debug "NumTo before clear = " + Str(CkEmail::ckNumTo(email))
; Remove all To recipients.
CkEmail::ckClearTo(email)
Debug "NumTo after clear = " + Str(CkEmail::ckNumTo(email))
CkEmail::ckDispose(email)
ProcedureReturn
EndProcedure