Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: Email Handler

  1. #1
    New Coder
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Email Handler

    I'm using a ASP email handler but it doesnt seem to work when I test it out...

    Code:
    <%
    Dim error
    error = 0
    For Each f In Request.Form
    If Request.Form(f) = "" Then 
    error = 1
    End If
    Next
    If error=1 Then
    response.redirect "error.html"
    Else
    Dim f, emsg, mail_to, r, o, c, other
    mail_to = "lnxusr86@netscape.net"
    fline = "_______________________________________________________________________"& vbNewLine 
    hline = vbNewLine & "_____________________________________"& vbNewLine 
    emsg = ""
    
    For Each f In Request.Form
    If mid(f,1,1)<>"S" = True Then 'do not save if input name starts with S
    emsg = emsg & f & " = " & Trim(Request.Form(f)) & hline
    End If
    Next
    
    Set objNewMail = Server.CreateObject("CDONTS.NewMail")
        objNewMail.From = Request("Email Address")
        objNewMail.Subject = "Message from contact page (version: 1.0)"
        objNewMail.To = mail_to
        objNewMail.Body = emsg & fline
        objNewMail.Send
        Set objNewMail = Nothing
    
    response.redirect "thankyou.html"
    End if
    %>
    Form

    Code:
                <form method="post" action="contactusprocess.asp"> 
    
    <input type="hidden" name="name" value="lnxusr86">
    
    <font class="normal2">Name:</font><br />
    <input name="name" maxlength="20"><br />
    
    <font class="normal2">URL or Email:</font><br />
    <input name="url" maxlength="100"> <br />
    
    <font class="normal2">Comment:</font><br />
    <textarea cols="26" rows="4" name="message" wrap></textarea><br />
    
    <input type="submit" value="Email"> 
    <input type="reset" value="Reset">
    
    
    </form>

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm. So it doesn't seem to work. Can you be a bit more precise about what does/doesn't happen?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    New Coder
    Join Date
    Jul 2004
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    emsg = emsg & f & " = " & Trim(Request.Form(f)) & hline
    End If
    Next

    objNewMail.Body = emsg & fline

    Is the objNewMail.Body supposed to state emsg & fline or just emsg?

  • #4
    New Coder
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    emsg = emsg & f & " = " & Trim(Request.Form(f)) & hline
    End If
    Next

    objNewMail.Body = emsg & fline

    Is the objNewMail.Body supposed to state emsg & fline or just emsg?
    I have no idea as I didnt write the script...

    Code:
    Hmm. So it doesn't seem to work. Can you be a bit more precise about what does/doesn't happen?
    When the send button is clicked the "email sent" page comes up as it should, but a email is never recieved at the destination...

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you would always get the message since you always redirect to the "thankyou.html"

    what adresses did you send it to? hotmail ?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #6
    New Coder
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what adresses did you send it to? hotmail ?
    Netscape...

    mail_to = "lnxusr86@netscape.net"

  • #7
    New Coder
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?

  • #8
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what email facilities do your webhost give you?

    some only allow for aspmail for instance..

    Code:
    Set objNewMail = Server.CreateObject("ASPMail.NewMail")
    might help..

    you could try something like this..

    Code:
    if Request.Form("formID") = "00" then
    
    	'Do some checks
    	if len(emailName) = 0 then
    		arrayErrors = arrayErrors & "|emailName"
    	end if
    	
    	if len(emailFrom) = 0 then
    		arrayErrors = arrayErrors & "|emailFrom"
    	else
    		if inStr(emailFrom,"@") = 0 or inStr(emailFrom,".") = 0 then
    			arrayErrors = arrayErrors & "|emailFrom"
    		end if
    		if invalidChar(emailFrom,1,"@.-_") then
    			arrayErrors = arrayErrors & "|emailFrom"
    		end if
    	end if
    	
    	if len(emailSubject) = 0 then
    		arrayErrors = arrayErrors & "|emailSubject"
    	end if
    	
    	if len(emailBody) = 0 then
    		arrayErrors = arrayErrors & "|emailBody"
    	end if
    	
    	'If there was no errors, send the email.
    	if len(trim(arrayErrors)) = 0 then
    	
    		'Send Email
    		call sendmail (emailName, emailFrom, emailTo, emailSubject, emailBody, 0)
    
    		'Say Thank You
    		response.redirect "sysMsg.asp?msg=" & server.URLEncode(langGenContactUsMsg)
    		
    	end if
    end if
    
    %>
    <!--#include file="_INCtop_.asp"-->
    
                      <table border="0" cellspacing="0" cellpadding="2" width="95%" align="center">
                        <tr>
    		<td valign=middle class="CPpageHead">
    			<b><%=langGenContactUsHdr%></b><br>
    		</td>
    	</tr>
    	<tr>
    		<form METHOD="POST" name="contactUs" action="contactUs.asp">
    		<td valign=top>
    			<br>
    <%
    			'If there were errors, show message
    			if len(trim(arrayErrors)) > 0 then
    				arrayErrors = split(LCase(arrayErrors),"|")
    				Response.Write "<font color=red><i>" & langErrInvForm & "</i></font><br><br>"
    			else
    				arrayErrors = array("")
    			end if
    %>
    			<%=langGenTo%> : <b><%=emailTo%></b><br><br>
    
    			<%=langGenYourName & " " & checkFieldError("emailName",arrayErrors)%><br>
    			<input type="text" name="emailName" size="20" maxlength="50" value="<%=emailName%>"><br>
    
    			<%=langGenEMail & " " & checkFieldError("emailFrom",arrayErrors)%><br>
    			<input type="text" name="emailFrom" size="20" maxlength="50" value="<%=emailFrom%>"><br>
    			
    			<%=langGenSubject & " " & checkFieldError("emailSubject",arrayErrors)%><br>
    			<input type="text" name="emailSubject" size="40" maxlength="50" value="<%=emailSubject%>"><br>
    
    			<%=langGenMessage & " " & checkFieldError("emailBody",arrayErrors)%><br>
    
    			<textarea name="emailBody" rows=6 cols="40" wrap="soft"><%=emailBody%></textarea><br><br>
    
    			<input type="hidden" name="formID" value="00">
    			<input type="SUBMIT" name="Submit" value="<%=langGenSend%>">
    
    		</td>
    		</form>
    	</tr>
    </table>
    
    <br>

  • #9
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Have you tried using the CDO object instead of CDONTS? If the webserver is Windows 2000 or higher, it will have it. There are differences between the two objects but you should have no trouble finding information on it.

    Also, are you making sure that the To, Subject, Body, and From fields have data in them? If one of them doesn't, the mail will not get sent and it will get dropped into the badmail folder on the server.

    Also, your host could have it setup so it will only send from addresses on the domain for the site.
    OracleGuy

  • #10
    New Coder
    Join Date
    Aug 2003
    Location
    Shawnee Mission, Kansas
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    X-Send will make this easy for ya:

    John Shepard
    Beyond The Impossible
    -----------------------------
    http://freeasphelp.tech.nu/
    FreeASPHelp by John Shepard
    Sign Up for a free account today!
    100% Free ASPHelp


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •