OT: CDONTS help

  • Thread starter Thread starter Mike Mueller
  • Start date Start date
M

Mike Mueller

I am trying to create a CDONTS asp page to pull contents from a form and
send to the correct distribution list. I am having a problew with the TO
property. If I set it static (mailer.to = "(e-mail address removed)) it all works
fine. I want it to change based on a value from the form and build a string
for it ( mailer.to= strDistibutionList where strDisributionList =
"(e-mail address removed); (e-mail address removed)). It does not send it to anyone then.
Comments or suggestions?

Mike
 
Hi Mike,
probably not what you want to hear but I wouldn't use cdonts any more - it's
obsolete. So when your host upgrades to win2003/iis6 your code won't run. As
you're writing new code why not use cdo now and save yourself re-writing
later.

Here's a quick intro to cdo
http://www.aspfaq.com/show.asp?id=2026

To send to more than 1 recipient you seperate with commas, eg
strTo = "(e-mail address removed), (e-mail address removed)"
oMail.to = strTo

Jon
Microsoft MVP - FP
 
-----Original Message-----
I am trying to create a CDONTS asp page to pull contents
from a form and send to the correct distribution list.
I am having a problew with the TO property. If I set it
static (mailer.to = "(e-mail address removed)) it all works
fine. I want it to change based on a value from the form
and build a string for it:
mailer.to= strDistibutionList
where
strDisributionList = "(e-mail address removed); (e-mail address removed)).
It does not send it to anyone then.

I agree that the CDO.Message object is far superior to
CDONTS.NewMail. Here's a simple example that uses
CDO.Message.

<body>
<form method="POST">
<input type="text" name="txtBody" size="20"><p>
<input type="submit" value="Submit" name="btnSub"></p>
</form>
<%
Const cdoSchema = _
"http://schemas.microsoft.com/cdo/configuration/"
if request("btnSub") <> "" then
Set objMsg = CreateObject("CDO.Message")
objMsg.Subject = "Test " & now()
objMsg.Sender = "(e-mail address removed)"
objMsg.To = "(e-mail address removed), (e-mail address removed)"
objMsg.TextBody = "The text box said, """ & _
request("txtBody") & """."
objMsg.Configuration.Fields.Item(cdoSchema & _
"sendusing") = 2
objMsg.Configuration.Fields.Item(cdoSchema & _
"smtpserver") = "smtp.whatever.com"
objMsg.Configuration.Fields.Item(cdoSchema & _
"smtpserverport") = 25
objMsg.Configuration.Fields.Update
objMsg.Send
end if
%>
</body>

This code presumes that the form has a Submit button named
btnSub. The statement
if request("btnSub") <> "" then
'
end if
therefore tests whether the form is running because the
visitor clicked a hyperlink on another page, or because
the visitor clicked the Submit button.

You can change the objMsg.TextBody = statement to format
the body of the message any way you want. Use the built-in
constant vbCrLf to create line breaks.

Alternatively, you can set objMsg.HtmlBody to a mess of
HTML, and the object will send HTML-formatted mail. Here's
an example.

objMsg.HtmlBody = _
"<html>" & vbCrLf & _
"<body>" & vbCrLf & _
"<table>" & vbCrLf & _
" <tr>" & vbCrLf& _
" <td>Name</td>" & vbCrLf& _
" <td>" & request("Name") & "</td>" & vbCrLf& _
" </tr>" & vbCrLf & _
" <tr>" & vbCrLf& _
" <td>Address</td>" & vbCrLf& _
" <td>" & request("Address") & "</td>" & vbCrLf& _
" </tr>" & vbCrLf & _
"</table>" & _
"</body>" & _
"</html>"

And of course, you'll want to change the subject, the
sender address, the To address, and the smtp server name
as well.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
Thanks Jon ( I think I've been saying that alot lately...)

My problem was a mistyped the variable being used. I found it when I created
a confirmation page and the field was blank. I new right after I sent the
post that it was probably a typo, but it was too late then

I can't upgrade to CDOSYS, as I am on an NT4 server-
http://support.microsoft.com/?kbid=810702

Mike
 
CDONTS is still supported under Windows 2003 Server / IIS6

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
only if your host installs it - it doesn't ship with 2003. You can copy
cdonts.dll but understandably many hosts wouldn't want to, in any case it
doesn't make much sense to use obsolete components when there's better
options available.

Jon
Microsoft MVP - FP
 
However, as long as MS includes it with the OS, even if you have to install
it (which you have to do with most of the internet related services under
Windows 2003 Server) or makes it available by other means, it is not
obsolete.

If you are just simply sending any email from a script based on a record
being added, etc. then it CDONTS is just fine, but it is not a good option
when sending to a large list (500 +) of email addresses.
--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
Thomas, it is NOT included in win2003 (or any current verion of windows)
that's the definition of obsolete. The only way to install it is to manually
copy cdonts.dll from a win2k box. From a hosts point of view they probably
don't want to install old stuff on their new servers.

ASP itself isn't good for sending for 500 + emails, unless you do something
like break them down into groups of say 50 BCCs. That volume of mail would
at least call for a mail component that supports queueing, eg aspqmail, if
not a listserv.

Jon
 
Jon,

I am using it on a hosted Windows 2003 server, I did not request to have it
installed, I just published my code to the site and it worked. So maybe the
host automatically mapped CDONTS to CDOSYS?

When I was running my local Windows 2000 server, (with all service packs) I
was also able to use CDONTS. However under Windows 2003, I have not bothered
to install the SMTP server/service.

So can you explain, how I am able to use something that is not installed or
included?
--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
If you're using cdonts on 2003 your host must have installed it. As I noted
previously it's easy to install cdonts on 2003 by resgsvr32ing cdonts.dll -
my point was that it isn't included.

Win2k supported both cdosys and cdonts to give developers time to migrate
away from cdonts to cdosys - if you try and use cdonts on a new install of
2003 (or XP Pro) you'll get an error like
Invalid class string or ActiveX component cant create cdonts.newmail

As long as cdonts works for you that's the most important thing, I don't
like to hang to old stuff until the bitter end - there's normally good
reasons for componenents to be replaced

Jon
Microsoft MVP - FP
 

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

Back
Top