PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
oleobject loo_Email
string ls_Repl
// 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).
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")
// Look up the replacement for a specific pattern.
ls_Repl = loo_Email.GetReplaceString2("FIRST_NAME")
Write-Debug "FIRST_NAME -> " + ls_Repl
destroy loo_Email