How to send mail in HTML format

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?
 
D

Daniel Bush

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)
 
P

Parker Zhang [MSFT]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top