DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
Boolean iSuccess
Integer n
Integer i
String sTemp1
// 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.
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
Showln "Pattern " i ": " sTemp1
Loop
End_Procedure