Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkEmailW.h>
void ChilkatSample(void)
{
HCkEmailW email;
const wchar_t *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).
email = CkEmailW_Create();
CkEmailW_putSubject(email,L"Hello FIRST_NAME");
CkEmailW_putBody(email,L"Dear FIRST_NAME, welcome to CITY.");
CkEmailW_SetReplacePattern(email,L"FIRST_NAME",L"John");
CkEmailW_SetReplacePattern(email,L"CITY",L"Denver");
// Look up the replacement for a specific pattern.
repl = CkEmailW_getReplaceString2(email,L"FIRST_NAME");
wprintf(L"FIRST_NAME -> %s\n",repl);
CkEmailW_Dispose(email);
}