Sample code for 30+ languages & platforms
Tcl

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 Tcl Downloads

Tcl

load ./chilkat.dll

#  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.

set email [new_CkEmail]

CkEmail_put_Subject $email "Hello FIRST_NAME"
CkEmail_put_Body $email "Dear FIRST_NAME, welcome to CITY."

CkEmail_SetReplacePattern $email "FIRST_NAME" "John"
CkEmail_SetReplacePattern $email "CITY" "Denver"

set n [CkEmail_get_NumReplacePatterns $email]

for {set i 0} {$i <= [expr $n - 1]} {incr i} {
    puts "Pattern $i: [CkEmail_getReplacePattern $email $i]"
}

delete_CkEmail $email