Re: Mail with HTML

#56824
Tom Henderson
Participant

We do something similar to send an email with a legal disclaimer in bold text.  The key is that email only really works with plain text, so the message has to be properly encoded with MIME for it to work correctly.  The format for HTML email is to MIME-encode the message as multipart/alternative, then supply the message as an HTML version (your document) and a plain text version.  Conceptually, each version carries the same message, but nothing really enforces that.  Spammers will often send out email where all the message is in the HTML part and the plain text part contains little or nothing.

The reason for this is so someone can read your email whether the email client supports HTML email or not.

Anyway, assuming that you a) have tcllib installed, which includes the MIME and SMTP extensions, and  b) have the HTML and plain-text message in an HTML file and a plain-text file named nogo.html and nogo.txt, and  c) change the email address and email server names to real-world values, this code should work.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10