How to send mail in HTML format

  • Thread starter Thread starter Paul Turley
  • Start date Start date
P

Paul Turley

How do I format a message so it shows up as a web page in the mail reader.
In the body of my message, I'm including a '<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Traditional//EN">' tag and standard <html><body> tags
but this all shows up as text in the message. What's the secret?
 
I can't get the SmtpMail object to work on our ISP's production server so
I'm stuck with using CDONTS in an ASP page. My code looks like this:

Set msg = CreateObject("CDONTS.NewMail")
msg.From = ...
...
msg.BodyFormat = 0 '-- This is the value of cdoBodyFormatHTML
msg.Body = ...
msg.Send()


<If there is a more appropriate group to post this to, please let me know.
I can't find a group for CDO>

Does your ISP support ASP.NET? Is the web page in question a ASP page
or a ASP.NET page. If ASP.NET, mail functions are exposed via a
different method than CDONTS or CDO.

I suspect you are using ASP not ASP.NET? If so, and if your ISP uses
Win2k or better, use CDO via ASP, not CDONTS. If you want to use CDO
as I suggest, check out the MSDN library URL:

http://msdn.microsoft.com/library/d...sys_about_cdo_for_windows_2000.asp?frame=true

For a short answer, if I recall correctly CDONTS will send the message
as HTML if you load up the property

msg.HTMLText=strText ' the var that holds your HTML

instead of

msg.Text=strText

Dan Bush
(e-mail address removed)
 
Hello,

I suggest you use the following code:

Dim iMsg
Dim iConf

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

Dim Flds
Set Flds = iConf.Fields

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"SMARTHOST"
.Update()
End With

With iMsg
.Configuration = iConf
.To = "<[email protected]>"
.From = "<[email protected]>"
.Subject = "hello"
.HTMLBody = "<html><b>Hello</b></html>"
.Send()
End With
 
Back
Top