"J. Alan Rueckgauer" wrote in message
news:Od**************@TK2MSFTNGP12.phx.gbl...
: "StephenMcC" <St********@discussions.microsoft.com> wrote in message
: news:61**********************************@microsof t.com...
: > If ur using CDO-NTS maybe have a look at HTMLText/Text properties of the
: Message object, using which depending on how recipient wishes to receive
: emails!?
: >
: [snip]
:
: The problem is creating the .TextBody. The source text is stored as HTML,
: so wrapping <html><body> around it and plopping it in .HtmlBody is a
: no-brainer. You can't just reassign the string for .HtmlBody to
..TextBody:
: it doesn't remove the HTML tags, so you get a text message that looks like
: "<html><body><h1>This Week's News</h1></body></html>" which is absolutely
: not what is wanted.
You would probably need to take 3 passes at it or have a more complex
Regular Expression but you could replace </p> with 2 vbCrLf, <br> or <br />
with 1 vbCrLf and then use a regexp to remove all HTML tags. Actually any
block elements should be replaced with vbCrLf.
Something like this...
<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
' converts HTML email to plain text
dim re, str, r
str = lcase("<HTML><HEAD><TITLE></TITLE></HEAD><BODY><p>Heading</p>line 1<br
/>line 2<br />line 3</BODY></HTML>")
str = replace(str,"<br />",vbCrLf)
str = replace(str,"</p>",vbCrLf & vbCrLf)
set re = new RegExp
re.Pattern = "<[^>]*>"
re.Global = true
re.IgnoreCase = true
r = re.replace(str,"")
Response.Write(r)
set re = nothing
%>
You can see it here but you need to view the source to see how it would turn
out in an email.
http://kiddanger.com/lab/htmlx.asp
FYI.. My email is set to plain text. I get plain text but if it is HTML
formatted, then the HTML version is an attachment. I never see the HTML
code in my plain text message body.
HTH...
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library -
http://msdn.microsoft.com/library/default.asp