|Subject:||Re: HTML Message with Embedded HTML Files|
|Posted by:||Kevin G. McCoy (atozedne…@idk-inc.com)|
|Date:||Fri, 28 Jan 2011|
On 1/28/2011 1:12 PM, Tom Hahn wrote:
> Delphi 7, Indy 10.5.8.0
> I wish to create an HTML message and embed (not attach) several HTML files
> within that message. I have never created a message that was not just plain
> text, so I am not sure how to accomplish this. An example would be
> appreciated since I don't even know how to start.
Write a template parser class that can replace macros in a text file
with strings. Read in a base HTML file (template) and then replace all
the macro tags with the appropriate strings. The strings can be HTML -
or not. Pass the modified template strings to SMTP.
You load all the text file lines of the template into a TStringList,
then step through the lines looking for known macros. I use "*Macro*"
in the template file because you can stuff *xxx* almost anywhere in an
HTML file and it won't crash the HTML editor. The Kompozer HTML editor
works for simple template editing, and it is free.
Anyway, when you find a matching macro tag pattern on a line, note the
location, delete the macro tag and replace it with the desired string.
Move on to the next macro tag or the next line of template.
I use a TList derived class to hold all my macro tags and replacement
values in dynamically created nodes.
This works well with simple mail-merge and dynamic HTML insertion. I use
this technique for membership mailing lists, automated email
notification, and so on.
If you want to allow the user to create their own "template" then use a
component like ProfGrid's TProfDHTMLEdit2. I don't know if this
component is compatible with D7 though.
Kevin G. McCoy
HTML Message with Embedded HTML Files posted by Tom Hahn on Fri, 28 Jan 2011