Simple HTML Text Messages

This case is identical to the plain text case above, except that you can include HTML markup commands in your text to give it "style". Most modern email readers understand HTML commands, even if you don’t bother to indicate in the header that you are using them. (But to be correct, you should set the EMF_HTMLBODY flag in opflags.) If the email reader does not understand HTML, then the reader will see your markup commands as if they were part of the text. But fortunately due to the nature of HTML commands, the text is still likely to be "readable", although the extent may depend on how complicated you make your HTML.

Here is a slightly more complicated example using a configuration file and a file for the body of the message:

EMAILX.CFG ------------------------------------------------

;EMAILX.SBX configuration file

WAIT      = 10                       ; 10 sec wait for server

SERVER    = localhost                ; SMTP server on local host

HOST      = sabionet.com             ; our domain id

DOMAIN    = microsabio.com           ; default domain for addresses

RTNADDR   = email@microsbio.com      ; default ‘FROM’ addr

REPLYTO   = replyto@microsabio.com   ; reply-to addr

LOGFILE   = EMAILX.LOG               ; name of log file

LOGLVL    = 2                        ; info summary

BODY1.TXT -------------------------------------------------

<HTML>

<HEAD><TITLE>This is the title</TITLE></HEAD>

<BODY>

<H1>This is Header #1</H1>

<H2>This is Header #2</H2>

<P>This is paragraph #1.

As you can see the formatting is based

on

the

P and /P notations and not on the

actual line breaks</P>

<P>This is paragraph #2</P>

</BODY></HTML>

 

EMHTML.BAS ------------------------------------------------

MAP1 EMAIL’PARAMS

   MAP2 EM’OPFLAGS,B,2

   MAP2 EM’TO,S,200

   MAP2 EM’CFGFILE,S,20,"EMAILX.CFG"

   MAP2 EM’FROM,S,50

   MAP2 EM’HEADER,S,1000

   MAP2 EM’BODY,S,30

   MAP2 EM’ERRMSG,S,100

   MAP2 CRLF$,S,2

   MAP2 EM’STATUS,F

 

++INCLUDE EMAILX.DEF      ! contains needed symbols

 

EM’OPFLAGS = EMF_BODYHTML

EM’TO = "test@microsabio.com"

CRLF$ = chr(13) + chr(10)

EM’HEADER = "To: HTML Test Department" + CRLF$ + "From: Field Research" + CRLF$ + "Subject: Testing HTML formatted message"

EM’BODY = "BODY1.TXT"

 

XCALL EMAILX,EM’OPFLAGS,EM’CFGFILE,EM’TO,EM’HEADER,EM’BODY, EM’STATUS,EM’FROM,"","",EM’ERRMSG

IF EM’STATUS # 0 then print "Error #";EM’STATUS;" – ";EM’ERRMSG