What is the best way to avoid using hard-coded string when creating an html string?

I’m creating an html message and sending it as an e-mail, I’m wondering what is the best way to avoid using hard-coded string when creating an html string? Macros and labels come to mind, I guess Macros is a better choice, what do you think?

I’m using AX 2009.

The answer depends on the character of data in your strings.

Labels are useful if the strings are language-dependent, which is likely not your case.

Macros are technically still hard-coded; the advantage is that you can have just a single definition, therefore they’re much easier to maintain (in comparison to having copies of the same string in many places). Nevertheless any change means that you have to change and redeploy code. It’s all right for things tightly-coupled with code.

Your other option is using parameters. For example, you might have parameter fields in database. Or you might have a template HTML file somewhere and just replace placeholder values, instead of building HTML file in code. Or so. It’s useful if it’s something what can change independently of code, because you can just change parameters and keep code intact. But if it’s coupled with code, making it configurable often makes little sense.