|
-
Jul 27th, 2010, 07:45 AM
#1
Thread Starter
Addicted Member
Send Email test and Option Explicit
I have a simple .asp page set up to test the functionality of the email sending on my web server. The code is below:
Code:
<% @ Language=VBScript %>
<!--#include file="includes/functions_send_mail.asp" -->
<%
Response.Expires=0
Response.ExpiresAbsolute =now()-1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl ="no-cache"
'Declare variables
Dim strEmailBody 'Holds the body of the e-mail message
Dim strRecipname 'Holds the Username of the recipient
Dim strRecipEmail 'Holds the email address of the recipient
Dim strSendername 'Holds the name of the sender
Dim strSenderEmail 'Holds the email address of the sender
Dim strSubject 'Holds the subject of the email
Dim strMailComponent
Dim blnEmailSent 'set to true if an e-mail is sent
'Set up email
strRecipname = "Recipient"
strRecipEmail = "[email protected]"
strSendername = "Sender"
strSenderEmail = "[email protected]"
strSubject = "Test Email function"
strMailComponent = "CDOSYS"
strEmailBody = "Hello Recipient,<br>This is a test email. So, please ignore.<br><br>Thanks"
'Call the function to send the e-mail
blnEmailSent = SendMail(strEmailBody, strRecipname, strRecipEmail, strSendername, strSenderEmail, strSubject, strMailComponent, true)
%>
<html>
<head>
<title>Test Email</title>
</head>
<body>
Email sent successfully! <%=blnEmailSent %>
</body>
</html>
The variable blnEmailSent is supposed to be True if the email was successfully sent, and False if not. But in practice, here's what happens. The page reports email sent True, but I never receive any email. (I have changed the email addresses in the code to protect the innocent )
If, however, I add the line <% Option Explicit %> after the Language line, the page reports email sent False, but I DO get the email. Can someone explain to me why this works in reverse, and why that line makes any difference?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|