cdosys cdonts question

Discussion in 'ASP General' started by Dr. Harvey Waxman, Dec 6, 2006.

  1. 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
    Dr. Harvey Waxman, Dec 6, 2006
    #1
    1. Advertising

  2. Dr. Harvey Waxman

    Mike Brind Guest

    See comments inline


    "Dr. Harvey Waxman" <> wrote in message
    news:-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
    Mike Brind, Dec 6, 2006
    #2
    1. Advertising

  3. 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 <>,
    "Mike Brind" <> wrote:

    > See comments inline
    >
    >
    > "Dr. Harvey Waxman" <> wrote in message
    > news:-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/
    Harvey Waxman, Dec 7, 2006
    #3
  4. Dr. Harvey Waxman

    Mike Brind Guest

    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" <> wrote in message
    news:-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 <>,
    > "Mike Brind" <> wrote:
    >
    >> See comments inline
    >>
    >>
    >> "Dr. Harvey Waxman" <> wrote in message
    >> news:-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/
    Mike Brind, Dec 7, 2006
    #4
  5. 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 <>,
    "Mike Brind" <> wrote:

    > 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/
    Harvey Waxman, Dec 7, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BB
    Replies:
    2
    Views:
    123
  2. Todd M. Taylor

    Hotmail blocks emails sent w/ CDONTS/CDOSYS????

    Todd M. Taylor, Feb 2, 2004, in forum: ASP General
    Replies:
    0
    Views:
    224
    Todd M. Taylor
    Feb 2, 2004
  3. Paxton

    CDONTS to CDOSYS

    Paxton, Nov 11, 2004, in forum: ASP General
    Replies:
    1
    Views:
    103
    Ray Costanzo [MVP]
    Nov 12, 2004
  4. tshad

    CDOSYS AND CDONTS on W2K3 machine

    tshad, Jan 14, 2005, in forum: ASP General
    Replies:
    15
    Views:
    252
    tshad
    Jan 18, 2005
  5. Jed

    CDONTS or CDOSYS UTF-8 Email

    Jed, Nov 8, 2006, in forum: ASP General
    Replies:
    10
    Views:
    308
Loading...

Share This Page