PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
oleobject loo_Email
integer n
integer i
// 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.
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
loo_Email.Subject = "Hello FIRST_NAME"
loo_Email.Body = "Dear FIRST_NAME, welcome to CITY."
loo_Email.SetReplacePattern("FIRST_NAME","John")
loo_Email.SetReplacePattern("CITY","Denver")
n = loo_Email.NumReplacePatterns
for i = 0 to n - 1
Write-Debug "Pattern " + string(i) + ": " + loo_Email.GetReplacePattern(i)
next
destroy loo_Email