DataFlex
DataFlex
Get a Mail-Merge Replacement String by Index
See more Email Object Examples
Demonstrates the Chilkat Email.GetReplaceString method, which returns the replacement string for the Nth previously-defined pattern/replacement pair (a mail-merge feature). The index is zero-based and corresponds to the same index used by GetReplacePattern. This example defines two pairs and prints each pattern with its replacement.
Background: Pairing
GetReplacePattern (the token to find) with GetReplaceString (the text to substitute) at the same index lets you walk the full mail-merge table. Retrieving a replacement by its position is handy when enumerating all substitutions; to look one up by its pattern instead, use GetReplaceString2.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
Boolean iSuccess
Integer n
Integer i
String sTemp1
String sTemp2
// Demonstrates the GetReplaceString method, which returns the replacement string for the
// Nth previously-defined pattern/replacement pair (a mail-merge feature). The index is
// zero-based and corresponds to the same index used by GetReplacePattern.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Hello FIRST_NAME"
Set ComBody Of hoEmail To "Dear FIRST_NAME, welcome to CITY."
Get ComSetReplacePattern Of hoEmail "FIRST_NAME" "John" To iSuccess
Get ComSetReplacePattern Of hoEmail "CITY" "Denver" To iSuccess
Get ComNumReplacePatterns Of hoEmail To n
For i From 0 To (n - 1)
Get ComGetReplacePattern Of hoEmail i To sTemp1
Get ComGetReplaceString Of hoEmail i To sTemp2
Showln sTemp1 " -> " sTemp2
Loop
End_Procedure