Archived Forum Post

Index of archived forum posts

Question:

merge field using visual foxpro

May 04 '14 at 19:17

Hi there

Is is possible to incorporate a mailmerge field into the chilkat email software. All i want to be able to do is incorporate a couple of merge fields so the email reads Dear FIRST_name in the email body etc.

Kind regards

Rob


Answer

I'm not sure of what the appropriate answer is for your question. I can say how I would do it...

I would create an HTML template, which might be a file, but could also simply be a string literal found directly within your source code. The template would use a keyword, such as "FIRST_NAME" that would be replaced using ordinary string operators in your programming language.

For example (in pseudo-code)

    string htmlTemplate = "<html><body>

Hello FIRST_NAME,<br></p><p>Thank you for ...</p> ..... </body></html>";

Then you would do your string substitutions (using whatever syntax or functionality is available in your programming language).

    string actualHtml = htmlTemplate.Replace("FIRST_NAME","Matt");
And then you would set the HTML body of the email using the actual HTML:
    email.SetHtmlBody(actualHtml);