Question : Checking ASP variable for nulls

I have a web form which executes an ASP script which sends an email message to me with contact details entered by the user. I want to check if they have entered an email address on the form, so I've inserted a test for a null value in the email address input field. If the email address input field is left empty by the user then the dummy email address ([email protected]) should be sent to me.
However, with this code, I don't receive the email message. What should be the correct code ?
I've attached the full script.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
<%
'Initialise objects and variables
Dim JMail, intComp, strReferer, strServer, strClientIP, strServerIP, blnSpam
Set JMail = Server.CreateObject("JMail.SMTPMail") 

'Check if this page is being called from a another page on the server
strReferer = request.servervariables("HTTP_REFERER")
strServer = Replace(request.servervariables("SERVER_NAME"), "www.", "")
strClientIP = request.servervariables("REMOTE_ADDR")
strServerIP = request.servervariables("LOCAL_ADDR")

intComp = inStr(strReferer, strServer)
If intComp > 0 Then 
	blnSpam = False
Else
	' Spam Attempt Block
	blnSpam = True
End If

' This is my local SMTP server
JMail.ServerAddress = "smtp." & strServer & ":25"

' This is me.... 
JMail.Sender = "noreply@" & strServer

SenderName = Request.Form("name")
SenderCompany = Request.Form("company")
SenderPhone = Request.Form("telephone")
SenderEmail = Request.Form("email")
Subject = "Enquiry to TOCO Training from "+ SenderName
Recipient = "[email protected]"
SenderComments = Request.Form("Comments")

Body = "Enquiry from " & SenderName & vbCrLf & "Company " & SenderCompany & vbCrLf & "Telephone " & SenderPhone & vbCrLf & "Email Address " & SenderEmail & vbCrLf & vbCrLf & SenderComments & vbCrLf

If SenderEmail = "" Then
   SenderEmail = "[email protected]"
End If

JMail.Sender = SenderEmail
JMail.Subject = Subject 

JMail.AddRecipient Recipient 

JMail.Body = Body 

JMail.Priority = 3 

JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR") 

'send mail
If NOT blnSpam Then
	JMail.Execute
	strResult = "Mail Sent."
Else
	strResult = "Mail Not Sent."
End If

Set jmail = Nothing

alertAndRedirect

Sub alertAndRedirect()
%>
<script><!--
alert("Thank you for your enquiry. We will contact you shortly.");
location.href="../contact.html";
// -->
</script>
<%
End Sub
%>

Answer : Checking ASP variable for nulls

you may look here. This is a long topic. In short terms better to use than not.

HTH

Ivo Stoykov
Random Solutions  
 
programming4us programming4us