PureBasic
PureBasic
Get a Mail-Merge Replace Pattern
See more Email Object Examples
Demonstrates the Chilkat Email.GetReplacePattern method, which returns a replacement pattern — the search string — previously defined for mail-merge operations with SetReplacePattern. The index is zero-based. This example defines two patterns and enumerates them.
Background: In Chilkat's mail-merge, each entry is a pattern (a placeholder token such as
FIRST_NAME) paired with a replacement string. GetReplacePattern retrieves the search side of the pair at a given index; GetReplaceString retrieves the matching replacement. Reading them back is useful for inspecting or logging exactly which substitutions will be applied when the message is sent.Chilkat PureBasic Downloads
IncludeFile "CkEmail.pb"
Procedure ChilkatExample()
; Demonstrates the GetReplacePattern method, which returns a replacement pattern (the
; search string) previously defined for mail-merge operations with SetReplacePattern.
; The index is zero-based.
email.i = CkEmail::ckCreate()
If email.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkEmail::setCkSubject(email, "Hello FIRST_NAME")
CkEmail::setCkBody(email, "Dear FIRST_NAME, welcome to CITY.")
CkEmail::ckSetReplacePattern(email,"FIRST_NAME","John")
CkEmail::ckSetReplacePattern(email,"CITY","Denver")
n.i = CkEmail::ckNumReplacePatterns(email)
i.i
For i = 0 To n - 1
Debug "Pattern " + Str(i) + ": " + CkEmail::ckGetReplacePattern(email,i)
Next
CkEmail::ckDispose(email)
ProcedureReturn
EndProcedure