Forum Moderators: open

Message Too Old, No Replies

Using CDONT for email forms for years

But my clients host doesn't allow it!

         

limbo

12:12 pm on Mar 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anyone got a link to a decent script that uses doesn't use CDONT. I am a complete .asp layman and need something quick and dirty for a client contact page

Thanks

Liam

mattur

1:52 pm on Mar 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some hosts turn off CDONTS but do provide an alternative component for sending email e.g. Jmail.

First thing to do is to find out what component the host supports for sending email from ASP...

limbo

1:59 pm on Mar 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Matt

Using CDOSYS now.

Does that help?

mattur

2:17 pm on Mar 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



CDONTS has been replaced by CDOSYS in Windows 2003, both are supported on w2k.

Here's a quick CDOSYS example:

<%
Set oMail = Server.CreateObject("CDO.Message")

oMail.To = strTo
oMail.From = strFrom
oMail.Subject = strSubject
oMail.TextBody = strMsg

oMail.Send

Set oMail = Nothing
%>

HTH

limbo

3:01 pm on Mar 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Matt

Thanks for your help. I don't really have the coding experience to decipher/understand the asp, nor the time to work out how, for now. I have botched a form with a CDOSYS script I found - it does what I need it to do bar submit the users name. Can you spot the error?


<%

If request("submit") <> "" THEN
Set objEMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Confi = objConfig.Fields
Confi("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
Confi("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\inetpub\mailroot\pickup"
Confi.Update
Set objEMail.Configuration = objConfig
objEMail.To = "my.email@email.com"
objEMail.From = Request("from")
objEMail.Subject = Request("subject")
objEMail.TextBody = Request("message")
objEMail.Send
Set objEMail = Nothing

Response.Write("<b>Thank you for submitting your enquiry</b>")
Else

%>

<form method="post" action="contact.asp">
Name
<INPUT type=text name="name" size="44">
E-mail
<INPUT type=text name="from" size="44">
Subject
<INPUT type=text name="subject" size="44">
Message
<TEXTAREA name="message" rows=10 cols=37></TEXTAREA>
<input type="reset" name="Reset" value="Reset">
<INPUT type="submit" value="Send" name="submit">

</form>

<%
End If
%>

Also is it easy to modify the above script so I can add/remove input boxes?

mattur

3:30 pm on Mar 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To include the user's name in the email message body, change the "objEMail.TextBody = ..." line to:

objEMail.TextBody = "Name: " & Request("name") & vbCRLF & vbCRLF & Request("message")

(adds the user name to message with two line breaks before the message box content)

To add other form fields into the message just add:

& vbCRLF & vbCRLF & Request("mynewfield")

to the end of the TextBody line above (it adds two line breaks then the contents of the form box "mynewfield" to the message).

limbo

9:16 am on Mar 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Matt

Works a treat.

Ta