| Home | Getting Started | Browse by Category | All functions |
One of the easiest ways to send a polished HTML email is to keep a reusable outer template file and merge your changing content into it.
This works especially well when you want to include:
If all you need is a clean wrapper with optional header and footer images, start with Simple HTML mode. Use this external-template approach when you want more control over the whole HTML frame.
With this approach, you leave the original template file untouched and write the merged result to a separate output file.
This pattern gives you a clean separation between:
That means you do not have to hand-build the whole HTML email inside Clarion, and you do not have to overwrite your master template every time you send a message.
A practical branded-template workflow looks like this:
Yes, every developer can write a mail-merge style search-and-replace function.
But vuMailKit already includes TokenMerge helpers, so you do not have to reinvent that plumbing in every application.
Another practical version of this pattern is to have a Clarion report write invoice or statement lines to a text file, then use TokenMergeFileIntoFile to place those generated lines into the email body before sending the merged output file.
Save the template as an external UTF-8 HTML file.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div style="text-align:center;">
<img src="vuMailKit270x90.gif" alt="Company Logo">
</div>
<hr>
<div>
[[MessageBody]]
</div>
<hr>
<p>LANSRAD<br>
Tennessee<br>
555-111-2222</p>
</body>
</html>
templatefile = 'HTMLFrame.txt'
mergedfile = 'EmailTarget.txt'
tokenText = '[[MessageBody]]'
valueText = '<p>Hello!</p><p>This message was created inside Clarion.</p>'
flags = 0
Result = TokenMergeInFile(templatefile, mergedfile, tokenText, valueText, flags)
cBody = mergedfile
templatefile = 'HTMLFrame.txt'
mergedfile = 'EmailTarget.txt'
replacementfile = 'MessageBody.txt'
tokenText = '[[MessageBody]]'
mergeFlags = 0
contentFlags = 1 ! Use 1 for plain text. Use 0 if MessageBody.txt already contains HTML.
Result = TokenMergeFileIntoFile(templatefile, mergedfile, tokenText, |
replacementfile, mergeFlags, contentFlags)
cBody = mergedfile
If the external HTML file contains accented letters or other international characters, save it as UTF-8.
That is the safest way to preserve special characters correctly.
Your template file stays unchanged. The merged file is the throwaway working copy that gets sent.
That makes it easy to reuse the same branded frame over and over.
If your outer file is HTML, the inserted content should normally be either plain text or an HTML fragment, not a full second HTML document.
When the replacement content is plain text, TokenMergeFileIntoFile can optionally convert normal line endings to <br> tags before insertion.
Use contentFlags = 1 when the replacement file is plain text. Use contentFlags = 0 when the replacement file already contains HTML markup.
If you want the logo to appear in the message body, the email must be sent as HTML.
This branded-template workflow is a very good fit for that.
You can build HTML directly inside Clarion if you want, but this external-template approach is often easier because:
| Home | Getting Started | Browse by Category | All functions |