473,320 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

cdosys cdonts question

I guess I should change from cdonts to cdosys. Since I am ignorant about asp I
hope you forgive this basic question. There are two asp files for handling
mail, the one that gets the info from a form and creates a form.asp to mail and
the one that takes that file and mails it, mail.asp.

I believe I can figure out what needs to be altered in the code for the first
form.asp but what needs to be changed in the one that sends the email? Is it
just this in the following code and if so just what should it read?

Thanks

Harvey

This is the 'mail.asp' file I use currently with cdonts.

Set objCDO = Server.CreateObject("CDONTS.NewMail")

'change this to the appropriate http
Const strHTTP = "http://www.righttax.org/"

'get current date
strDate = Date()

'get form information
strFormName = Request("FormName")
strSubject = Request("subject")
strSendTo = Request("SendTo")

strName = Request("txtName")
strPhone = Request("txtPhone")

'if no information entered for email use your own
if instr(Request("txtEmail"), "@") <0 then
strFrom = Request("txtEmail")
else
strFrom = strSendTo
end if

'concat URL information
strURLInfo = strHTTP & strFormName & "?" & Request.Form()

'create the HTML for email
strHTML = "<HTML<HEAD<TITLE></TITLE</HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=0>"
strHTML = strHTML & "<TR>"

'use some graphics for email
strHTML = strHTML & "<TD><IMG SRC=" & strHTTP & "emailbanner.JPG
BORDER=0></TD>"
strHTML = strHTML & "</TR>"

'include basic info in email
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD>"
strHTML = strHTML & "<BR>Date: " & strDate
strHTML = strHTML & "<BR>Subject: " & strSubject
strHTML = strHTML & "<BR>Requested by: " & strName
strHTML = strHTML & "<BR>Phone: " & strPhone

if strFrom <strSendTo then
strHTML = strHTML & "<BR>Email: <a href=mailto:" & strFrom & ">" &
strFrom & "</a>"
else
strHTML = strHTML & "<BR>Email: UNKNOWN"
end if

'add hyperlink to form in email
strHTML = strHTML & "<BR><BR>"
strHTML = strHTML & "<A HREF=" & strURLInfo & "><IMG SRC=" & strHTTP &
"form.gif WIDTH=16 HEIGHT=16 BORDER=0>Click here</A>"
strHTML = strHTML & " to view completed form."
strHTML = strHTML & "</TD>"
strHTML = strHTML & "</TR>"
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD></TD>"
strHTML = strHTML & "</TR>"
strHTML = strHTML & "</TABLE>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"
'time to send the email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")

objCDO.To = strSendTo
objCDO.From = strFrom
objCDO.Subject = strName & " - " & strSubject
objCDO.BodyFormat = 0
objCDO.MailFormat = 0
objCDO.Body = strHTML
objCDO.Send

set objCDO = nothing

'redirect to the "Thanks" page
'Response.Redirect strHTTP & "index.html"
--
RIGHT
Remove spam to email
http://righttax.org
Dec 6 '06 #1
4 2037
See comments inline
"Dr. Harvey Waxman" <sp******@righttax.orgwrote in message
news:sp****************************@news.lga.highw inds-media.com...
>I guess I should change from cdonts to cdosys. Since I am ignorant about
asp I
hope you forgive this basic question. There are two asp files for
handling
mail, the one that gets the info from a form and creates a form.asp to
mail and
the one that takes that file and mails it, mail.asp.

I believe I can figure out what needs to be altered in the code for the
first
form.asp but what needs to be changed in the one that sends the email? Is
it
just this in the following code and if so just what should it read?

Thanks

Harvey

This is the 'mail.asp' file I use currently with cdonts.

Set objCDO = Server.CreateObject("CDONTS.NewMail")
Get rid of the above line - it's repeated later and at a more appropriate
point - ie just before you use the object you are creating.
>
'change this to the appropriate http
Const strHTTP = "http://www.righttax.org/"

'get current date
strDate = Date()

'get form information
strFormName = Request("FormName")
strSubject = Request("subject")
strSendTo = Request("SendTo")

strName = Request("txtName")
strPhone = Request("txtPhone")

'if no information entered for email use your own
if instr(Request("txtEmail"), "@") <0 then
strFrom = Request("txtEmail")
else
strFrom = strSendTo
end if
Change all these Request("something") to Request.Form("something") or
Request.Querystring("something") - whichever collection you are using (not
germane to using CDO, but you should do this)

'concat URL information
strURLInfo = strHTTP & strFormName & "?" & Request.Form()

'create the HTML for email
strHTML = "<HTML<HEAD<TITLE></TITLE</HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=0>"
strHTML = strHTML & "<TR>"

'use some graphics for email
strHTML = strHTML & "<TD><IMG SRC=" & strHTTP & "emailbanner.JPG
BORDER=0></TD>"
strHTML = strHTML & "</TR>"

'include basic info in email
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD>"
strHTML = strHTML & "<BR>Date: " & strDate
strHTML = strHTML & "<BR>Subject: " & strSubject
strHTML = strHTML & "<BR>Requested by: " & strName
strHTML = strHTML & "<BR>Phone: " & strPhone

if strFrom <strSendTo then
strHTML = strHTML & "<BR>Email: <a href=mailto:" & strFrom & ">" &
strFrom & "</a>"
else
strHTML = strHTML & "<BR>Email: UNKNOWN"
end if

'add hyperlink to form in email
strHTML = strHTML & "<BR><BR>"
strHTML = strHTML & "<A HREF=" & strURLInfo & "><IMG SRC=" & strHTTP &
"form.gif WIDTH=16 HEIGHT=16 BORDER=0>Click here</A>"
strHTML = strHTML & " to view completed form."
strHTML = strHTML & "</TD>"
strHTML = strHTML & "</TR>"
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD></TD>"
strHTML = strHTML & "</TR>"
strHTML = strHTML & "</TABLE>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"
String concatenation is awful. Taking the first 4 lines as an example, use
the underscore character for continuation:

strHTML = "<HTML<HEAD<TITLE></TITLE</HEAD>" & _
"<BODY>" & _
"<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=0>" & _
"<TR>"

Again, not germane to using CDO, but the way it's currently being done is
very inefficient
>
'time to send the email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")
Change the above to Set objCDO = Server.CreateObject("CDO.Message")
>
objCDO.To = strSendTo
objCDO.From = strFrom
objCDO.Subject = strName & " - " & strSubject
objCDO.BodyFormat = 0
objCDO.MailFormat = 0
Get rid of the above 2 lines
objCDO.Body = strHTML
Change the above line to objCDO.HTMLBody = strHTML
objCDO.Send

set objCDO = nothing

'redirect to the "Thanks" page
'Response.Redirect strHTTP & "index.html"

That should do it.

--
Mike Brind
Dec 6 '06 #2
I'll try those changes. What happens if one has two such files, do they both
send out an email? Is it critical to have the .asp extent in the file name?

Thanks for the help.

Harvey

In article <uT**************@TK2MSFTNGP02.phx.gbl>,
"Mike Brind" <pa*******@hotmail.comwrote:
See comments inline
"Dr. Harvey Waxman" <sp******@righttax.orgwrote in message
news:sp****************************@news.lga.highw inds-media.com...
I guess I should change from cdonts to cdosys. Since I am ignorant about
asp I
hope you forgive this basic question. There are two asp files for
handling
mail, the one that gets the info from a form and creates a form.asp to
mail and
the one that takes that file and mails it, mail.asp.

I believe I can figure out what needs to be altered in the code for the
first
form.asp but what needs to be changed in the one that sends the email? Is
it
just this in the following code and if so just what should it read?

Thanks

Harvey

This is the 'mail.asp' file I use currently with cdonts.

Set objCDO = Server.CreateObject("CDONTS.NewMail")

Get rid of the above line - it's repeated later and at a more appropriate
point - ie just before you use the object you are creating.

'change this to the appropriate http
Const strHTTP = "http://www.righttax.org/"

'get current date
strDate = Date()

'get form information
strFormName = Request("FormName")
strSubject = Request("subject")
strSendTo = Request("SendTo")

strName = Request("txtName")
strPhone = Request("txtPhone")

'if no information entered for email use your own
if instr(Request("txtEmail"), "@") <0 then
strFrom = Request("txtEmail")
else
strFrom = strSendTo
end if

Change all these Request("something") to Request.Form("something") or
Request.Querystring("something") - whichever collection you are using (not
germane to using CDO, but you should do this)

'concat URL information
strURLInfo = strHTTP & strFormName & "?" & Request.Form()

'create the HTML for email
strHTML = "<HTML<HEAD<TITLE></TITLE</HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=0>"
strHTML = strHTML & "<TR>"

'use some graphics for email
strHTML = strHTML & "<TD><IMG SRC=" & strHTTP & "emailbanner.JPG
BORDER=0></TD>"
strHTML = strHTML & "</TR>"

'include basic info in email
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD>"
strHTML = strHTML & "<BR>Date: " & strDate
strHTML = strHTML & "<BR>Subject: " & strSubject
strHTML = strHTML & "<BR>Requested by: " & strName
strHTML = strHTML & "<BR>Phone: " & strPhone

if strFrom <strSendTo then
strHTML = strHTML & "<BR>Email: <a href=mailto:" & strFrom & ">" &
strFrom & "</a>"
else
strHTML = strHTML & "<BR>Email: UNKNOWN"
end if

'add hyperlink to form in email
strHTML = strHTML & "<BR><BR>"
strHTML = strHTML & "<A HREF=" & strURLInfo & "><IMG SRC=" & strHTTP &
"form.gif WIDTH=16 HEIGHT=16 BORDER=0>Click here</A>"
strHTML = strHTML & " to view completed form."
strHTML = strHTML & "</TD>"
strHTML = strHTML & "</TR>"
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD></TD>"
strHTML = strHTML & "</TR>"
strHTML = strHTML & "</TABLE>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

String concatenation is awful. Taking the first 4 lines as an example, use
the underscore character for continuation:

strHTML = "<HTML<HEAD<TITLE></TITLE</HEAD>" & _
"<BODY>" & _
"<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=0>" & _
"<TR>"

Again, not germane to using CDO, but the way it's currently being done is
very inefficient

'time to send the email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")

Change the above to Set objCDO = Server.CreateObject("CDO.Message")

objCDO.To = strSendTo
objCDO.From = strFrom
objCDO.Subject = strName & " - " & strSubject
objCDO.BodyFormat = 0
objCDO.MailFormat = 0

Get rid of the above 2 lines
objCDO.Body = strHTML

Change the above line to objCDO.HTMLBody = strHTML
objCDO.Send

set objCDO = nothing

'redirect to the "Thanks" page
'Response.Redirect strHTTP & "index.html"

That should do it.

--
Mike Brind


--
Harvey Waxman
remove spam to email
http://righttax.org/
Dec 7 '06 #3
The form that collects the information will have an action attribute. This
should point to the file that processes the data and generates and sends the
email. An asp file can only do it's thing if it is called in such a way, or
requested directly (eg if someone types http://www.domainname/filename.asp
in their browser address bar). It can also be called if there is an
instruction in another file that is called to response.redirect
"filename.asp", <!--#include file="filename.asp"-->,
server.execute("filename.asp") or server.transfer("filename.asp").

In your case, unless there is a reason to generate 2 emails, I can't see
what the purpose of the second file is. Maybe it's an old version, or a
duplicate for some reason, or maybe, since I seem to recall you suggesting
this was provided by your hosting company, it's there to generate emails
using a different configuration or component.

Finally, if you want the asp code to execute in the file, you need to leave
the .asp extension alone. That way, you are guaranteed that the web server
knows to send the file to the ASP engine for processing. It is possible to
configure the web server to process any and all files as if they are asp
files, but rarely done in practice. It is highly unlikely that you would
get a commercial web hosting company to agree to do this unless you have a
dedicated server or something.

--
Mike Brind

"Harvey Waxman" <sp*********@cox.netwrote in message
news:sp*******************************@news.lga.hi ghwinds-media.com...
I'll try those changes. What happens if one has two such files, do they
both
send out an email? Is it critical to have the .asp extent in the file
name?

Thanks for the help.

Harvey

In article <uT**************@TK2MSFTNGP02.phx.gbl>,
"Mike Brind" <pa*******@hotmail.comwrote:
>See comments inline
"Dr. Harvey Waxman" <sp******@righttax.orgwrote in message
news:sp****************************@news.lga.high winds-media.com...
>I guess I should change from cdonts to cdosys. Since I am ignorant
about
asp I
hope you forgive this basic question. There are two asp files for
handling
mail, the one that gets the info from a form and creates a form.asp to
mail and
the one that takes that file and mails it, mail.asp.

I believe I can figure out what needs to be altered in the code for the
first
form.asp but what needs to be changed in the one that sends the email?
Is
it
just this in the following code and if so just what should it read?

Thanks

Harvey

This is the 'mail.asp' file I use currently with cdonts.

Set objCDO = Server.CreateObject("CDONTS.NewMail")

Get rid of the above line - it's repeated later and at a more appropriate
point - ie just before you use the object you are creating.
>
'change this to the appropriate http
Const strHTTP = "http://www.righttax.org/"

'get current date
strDate = Date()

'get form information
strFormName = Request("FormName")
strSubject = Request("subject")
strSendTo = Request("SendTo")

strName = Request("txtName")
strPhone = Request("txtPhone")

'if no information entered for email use your own
if instr(Request("txtEmail"), "@") <0 then
strFrom = Request("txtEmail")
else
strFrom = strSendTo
end if

Change all these Request("something") to Request.Form("something") or
Request.Querystring("something") - whichever collection you are using
(not
germane to using CDO, but you should do this)

'concat URL information
strURLInfo = strHTTP & strFormName & "?" & Request.Form()

'create the HTML for email
strHTML = "<HTML<HEAD<TITLE></TITLE</HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=0>"
strHTML = strHTML & "<TR>"

'use some graphics for email
strHTML = strHTML & "<TD><IMG SRC=" & strHTTP & "emailbanner.JPG
BORDER=0></TD>"
strHTML = strHTML & "</TR>"

'include basic info in email
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD>"
strHTML = strHTML & "<BR>Date: " & strDate
strHTML = strHTML & "<BR>Subject: " & strSubject
strHTML = strHTML & "<BR>Requested by: " & strName
strHTML = strHTML & "<BR>Phone: " & strPhone

if strFrom <strSendTo then
strHTML = strHTML & "<BR>Email: <a href=mailto:" & strFrom & ">" &
strFrom & "</a>"
else
strHTML = strHTML & "<BR>Email: UNKNOWN"
end if

'add hyperlink to form in email
strHTML = strHTML & "<BR><BR>"
strHTML = strHTML & "<A HREF=" & strURLInfo & "><IMG SRC=" & strHTTP
&
"form.gif WIDTH=16 HEIGHT=16 BORDER=0>Click here</A>"
strHTML = strHTML & " to view completed form."
strHTML = strHTML & "</TD>"
strHTML = strHTML & "</TR>"
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD></TD>"
strHTML = strHTML & "</TR>"
strHTML = strHTML & "</TABLE>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

String concatenation is awful. Taking the first 4 lines as an example,
use
the underscore character for continuation:

strHTML = "<HTML<HEAD<TITLE></TITLE</HEAD>" & _
"<BODY>" & _
"<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=0>" & _
"<TR>"

Again, not germane to using CDO, but the way it's currently being done is
very inefficient
>
'time to send the email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")

Change the above to Set objCDO = Server.CreateObject("CDO.Message")
>
objCDO.To = strSendTo
objCDO.From = strFrom
objCDO.Subject = strName & " - " & strSubject
objCDO.BodyFormat = 0
objCDO.MailFormat = 0

Get rid of the above 2 lines
objCDO.Body = strHTML

Change the above line to objCDO.HTMLBody = strHTML
objCDO.Send

set objCDO = nothing

'redirect to the "Thanks" page
'Response.Redirect strHTTP & "index.html"


That should do it.

--
Mike Brind

--
Harvey Waxman
remove spam to email
http://righttax.org/

Dec 7 '06 #4
Thanks Mike.

I wasn't suggesting to have two asp files. I was trying to better understand
the relationship between the files and the significance of name extents.

You did a good job of explaining it.

In article <er**************@TK2MSFTNGP02.phx.gbl>,
"Mike Brind" <di*********@microsoft.comwrote:
The form that collects the information will have an action attribute. This
should point to the file that processes the data and generates and sends the
email. An asp file can only do it's thing if it is called in such a way, or
requested directly (eg if someone types http://www.domainname/filename.asp
in their browser address bar). It can also be called if there is an
instruction in another file that is called to response.redirect
"filename.asp", <!--#include file="filename.asp"-->,
server.execute("filename.asp") or server.transfer("filename.asp").

In your case, unless there is a reason to generate 2 emails, I can't see
what the purpose of the second file is. Maybe it's an old version, or a
duplicate for some reason, or maybe, since I seem to recall you suggesting
this was provided by your hosting company, it's there to generate emails
using a different configuration or component.

Finally, if you want the asp code to execute in the file, you need to leave
the .asp extension alone. That way, you are guaranteed that the web server
knows to send the file to the ASP engine for processing. It is possible to
configure the web server to process any and all files as if they are asp
files, but rarely done in practice. It is highly unlikely that you would
get a commercial web hosting company to agree to do this unless you have a
dedicated server or something.


--
Harvey Waxman
remove spam to email
http://righttax.org/
Dec 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: BB | last post by:
For send mail from a web page is there any benefit in using CDOSYS over CDONTS? Are the methods the same? How do you Set the object? Thanks BB
3
by: Andy | last post by:
Hi Aarron Your code below helped me move from CDONTS email to CDOSYS email. My one question is how do I set this CDOSYS email as HTML formatted email. As it is now it just sends straight text....
6
by: Peter Croft | last post by:
Hello. Can someone please tell me how to set the priority of an email message sent from an ASP script using CDOSYS as below - set oCdoMsg = server.createobject("CDO.Message") oCdoMsg.from=......
1
by: Paxton | last post by:
Is it necessary to set field configurations for CDOSYS? I have yet to recode all my existing uses of CDONTS over to CDOSYS. In most of the sample code I've seen on the usual ASP sites, there is...
16
by: tshad | last post by:
I have both cdosys.dll and cdonts.dll on my W2K3 server. We have been told by our web authors that their asp code won't work on our machine and that we don't have CDONTS installed on our machine....
1
by: aRBee | last post by:
I got the all too typical Unable to access CDO.Message object error. I checked the registry for HKEY_CLASSES_ROOT\CDO.Message\CLSID and the default value was blank. I unregistered all CDO dlls:...
10
by: Jed | last post by:
I have a form that needs to handle international characters withing the UTF-8 character set. I have tried all the recommended strategies for getting utf-8 characters from form input to email...
12
by: Basr | last post by:
My provider removed suddenly the CDONTS from the server. Now I have to change my forms and I have to use the CDOSYS functionaltity Till now I used one script that could do the work with one page....
0
by: david220 | last post by:
hi once members sign up to my site they get sent an email which contains there username/password which they enter on a sign up form. Once they've signed up the email is automatically sent using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.