B
Bobby Howell
Hi.
I have the following which I use either on my server using cscript (.vbs
file) or identical code in my ASP pages. The problem is when running in ASP
I recieve the following error:
Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'iMsg'
/scripts/processdata.asp, line 257
The error is raised when my DeallocateResouces procedure attempts to
deallocate resources for objects (set iMsg = Nothing). However, when I run
my .vbs file which is on the server using wscript or cscript all is fine.
Just like in VB. The only difference is the QuitOnError() procedure. In
the ASP file I use scripting to popup alert to user. However in .vbs file
on server I write events to app log.
Why don't my procedures have access to the variables in asp, but do in
standard vbs files? How do I fix? As you know, by default procedures are
public. Thank you in advance
<<<<<Code of .asp file used on web and also in .vbs file on server>>>>
..
..
..
call SendEmail
call DeallocateResources
sub SendEmail
' on error resume next
dim iMsg, iConf, Flds
const cdoSendUsingPort = 2
set iMsg = CreateObject("CDO.Message")
call QuitOnError
set iConf = CreateObject("CDO.Configuration")
call QuitOnError
set Flds = iConf.Fields
call QuitOnError
..
..
..
end sub
sub DeallocateResources()
' on error resume next
set iMsg = Nothing
set iConf = Nothing
set Flds = Nothing
end sub
sub QuitOnError()
' on error resume next
if err.number <> 0 then
%>
<script language="vbscript">
alert("Your message could not be sent at this time. Please click the
Back button and try again.")
</script>
<%
call DeallocateResources
Response.Clear
Response.End
end if
end sub
I have the following which I use either on my server using cscript (.vbs
file) or identical code in my ASP pages. The problem is when running in ASP
I recieve the following error:
Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'iMsg'
/scripts/processdata.asp, line 257
The error is raised when my DeallocateResouces procedure attempts to
deallocate resources for objects (set iMsg = Nothing). However, when I run
my .vbs file which is on the server using wscript or cscript all is fine.
Just like in VB. The only difference is the QuitOnError() procedure. In
the ASP file I use scripting to popup alert to user. However in .vbs file
on server I write events to app log.
Why don't my procedures have access to the variables in asp, but do in
standard vbs files? How do I fix? As you know, by default procedures are
public. Thank you in advance
<<<<<Code of .asp file used on web and also in .vbs file on server>>>>
..
..
..
call SendEmail
call DeallocateResources
sub SendEmail
' on error resume next
dim iMsg, iConf, Flds
const cdoSendUsingPort = 2
set iMsg = CreateObject("CDO.Message")
call QuitOnError
set iConf = CreateObject("CDO.Configuration")
call QuitOnError
set Flds = iConf.Fields
call QuitOnError
..
..
..
end sub
sub DeallocateResources()
' on error resume next
set iMsg = Nothing
set iConf = Nothing
set Flds = Nothing
end sub
sub QuitOnError()
' on error resume next
if err.number <> 0 then
%>
<script language="vbscript">
alert("Your message could not be sent at this time. Please click the
Back button and try again.")
</script>
<%
call DeallocateResources
Response.Clear
Response.End
end if
end sub