DataFlex
DataFlex
Get a Mail-Merge Replacement String by Pattern
See more Email Object Examples
Demonstrates the Chilkat Email.GetReplaceString2 method, which returns the replacement string for a previously-defined pattern/replacement pair, looked up by the pattern itself (a mail-merge feature). This example defines two pairs and looks up the replacement for one pattern by name.
Background: Where
GetReplaceString fetches a replacement by its numeric position, GetReplaceString2 fetches it by the pattern — convenient when you already know the token (say FIRST_NAME) and just want its configured substitution without scanning the whole list.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
Boolean iSuccess
String sRepl
// Demonstrates the GetReplaceString2 method, which returns the replacement string for a
// previously-defined pattern/replacement pair, looked up by the pattern itself (a
// mail-merge feature).
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
// Look up the replacement for a specific pattern.
Get ComGetReplaceString2 Of hoEmail "FIRST_NAME" To sRepl
Showln "FIRST_NAME -> " sRepl
End_Procedure