...

View Full Version : Email Handler



lnxusr86
07-15-2004, 06:07 PM
I'm using a ASP email handler but it doesnt seem to work when I test it out...


<%
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



<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>

raf
07-15-2004, 10:11 PM
Hmm. So it doesn't seem to work. Can you be a bit more precise about what does/doesn't happen?

npala2001
07-15-2004, 10:58 PM
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?

lnxusr86
07-16-2004, 02:50 PM
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...


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...

raf
07-16-2004, 03:28 PM
you would always get the message since you always redirect to the "thankyou.html"

what adresses did you send it to? hotmail ?

lnxusr86
07-16-2004, 05:19 PM
what adresses did you send it to? hotmail ?

Netscape...


mail_to = "lnxusr86@netscape.net"

lnxusr86
07-20-2004, 07:29 PM
anyone?

startbar
07-20-2004, 10:12 PM
what email facilities do your webhost give you?

some only allow for aspmail for instance..


Set objNewMail = Server.CreateObject("ASPMail.NewMail")

might help..

you could try something like this..


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>

oracleguy
07-20-2004, 10:45 PM
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.

freeasphelp
07-21-2004, 04:52 PM
Get X-Send now!

http://www28.brinkster.com/freeasphelp/#Downloads



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum