I'm trying to get a DLL created that will allow my to port into a POP3 account via a ASP page. I was able to get it to work on my computer (WinXP Pro) using a LocalHost webserver. BUT when I put it on our Win2k Server - Web Server I get a message saying Server Cannot Create Object. It's the same ASP and DLL that works on my machine. Is anyone familiar with how this could happen? Thanks =)
Andrew
Below is the Code
-----[Begin DLL]-------------------------------------------
Option Explicit
'Some code borrowed from WnsckFormDLL
Private WithEvents WSock As Winsock
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim output, Username1, Password1, Site1 As String
Private Sub Class_Initialize()
Set WSock = New Winsock
End Sub
Private Sub Class_Terminate()
If WSock.State = 7 Then WSock.Close
Do
Pause (500)
Loop While WSock.State = 7
Set WSock = Nothing
End Sub
Public Function GetMyMail(Username As String, Optional Password _
As String, Optional Site As String, Optional Port As String)
output = "User: " & Username & vbCrLf
Username1 = Username
Password1 = Password
Site1 = Site
With WSock
If .State <> 0 Then
.Close
Do
Loop Until .State = 0
End If
.RemoteHost = Site
.RemotePort = Port
.Connect
Do
Pause (500)
Loop Until .State > 6
Select Case .State
Case 9
output = output & "Error Connecting To Server - Case 9<br>"
Case 8
output = output & "Error Connecting To Server - Case 8<br>"
Case 7
output = output & "Connected To Server!" & vbCrLf
ReadLine
Login
GetLast
.SendData "Quit" & vbCrLf
Pause (500)
End Select
End With
GetMyMail = "<textarea name=""txtarea"" rows=""25"" cols=""80"">" _
& output & "</textarea><br>"
End Function
Private Sub ReadLine()
Dim InData As String
Dim intTimeOut As Integer
intTimeOut = 0
InData = ""
Do
intTimeOut = intTimeOut + 1
WSock.GetData InData
If intTimeOut > 12 And InData = "" Then InData = _
"ERROR - Timeout Occured After " & intTimeOut / 2 & " Seconds."
If InData = "" Then Pause (500)
Loop While InData = ""
output = output & InData & vbCrLf
End Sub
Private Sub Login()
WSock.SendData "USER " & Username1 & vbCrLf
output = output & "USER " & Username1 & vbCrLf
ReadLine
WSock.SendData "PASS " & Password1 & vbCrLf
output = output & "PASS " & Password1 & vbCrLf
ReadLine
End Sub
Private Sub GetLast()
Dim InData As String
Dim intTimeOut As Integer
Dim strLastMsg As String
Dim intLastMsg As Integer
WSock.SendData "LAST" & vbCrLf
intTimeOut = 0
InData = ""
Do
intTimeOut = intTimeOut + 1
WSock.GetData InData
If intTimeOut > 12 And InData = "" Then InData = _
"ERROR - Timeout Occured After " & intTimeOut / 2 & " Seconds."
If InData = "" Then Pause (500)
Loop While InData = ""
strLastMsg = Mid$(InData, 4)
intLastMsg = CInt(strLastMsg)
intLastMsg = intLastMsg + 1
output = output & "Getting Message " & intLastMsg & vbCrLf
WSock.SendData "RETR " & intLastMsg & vbCrLf
ReadLine
End Sub
Private Sub Pause(Interval As Long)
Dim Start
Start = GetTickCount
Do While GetTickCount < Start + Interval
DoEvents
Loop
End Sub
-----[End DLL]---------------------------------------------
-----[Begin ASP]-------------------------------------------
<%
dim strOutput, strUser, strPass, strSite, strPort, objMailDll
set objMailDll = Server.CreateObject("AspConx.Mail"
strUser = Request.Form("Username"
strPass = Request.Form("Password"
strSite = Request.Form("Site"
strPort = Request.Form("Port"
strOutput = objMailDll.GetMyMail(strUser, strPass, strSite, strPort)
response.Write strOutput & "<br>"
set objMailDll = Nothing
%>
-----[End ASP]---------------------------------------------
Andrew
Below is the Code
-----[Begin DLL]-------------------------------------------
Option Explicit
'Some code borrowed from WnsckFormDLL
Private WithEvents WSock As Winsock
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim output, Username1, Password1, Site1 As String
Private Sub Class_Initialize()
Set WSock = New Winsock
End Sub
Private Sub Class_Terminate()
If WSock.State = 7 Then WSock.Close
Do
Pause (500)
Loop While WSock.State = 7
Set WSock = Nothing
End Sub
Public Function GetMyMail(Username As String, Optional Password _
As String, Optional Site As String, Optional Port As String)
output = "User: " & Username & vbCrLf
Username1 = Username
Password1 = Password
Site1 = Site
With WSock
If .State <> 0 Then
.Close
Do
Loop Until .State = 0
End If
.RemoteHost = Site
.RemotePort = Port
.Connect
Do
Pause (500)
Loop Until .State > 6
Select Case .State
Case 9
output = output & "Error Connecting To Server - Case 9<br>"
Case 8
output = output & "Error Connecting To Server - Case 8<br>"
Case 7
output = output & "Connected To Server!" & vbCrLf
ReadLine
Login
GetLast
.SendData "Quit" & vbCrLf
Pause (500)
End Select
End With
GetMyMail = "<textarea name=""txtarea"" rows=""25"" cols=""80"">" _
& output & "</textarea><br>"
End Function
Private Sub ReadLine()
Dim InData As String
Dim intTimeOut As Integer
intTimeOut = 0
InData = ""
Do
intTimeOut = intTimeOut + 1
WSock.GetData InData
If intTimeOut > 12 And InData = "" Then InData = _
"ERROR - Timeout Occured After " & intTimeOut / 2 & " Seconds."
If InData = "" Then Pause (500)
Loop While InData = ""
output = output & InData & vbCrLf
End Sub
Private Sub Login()
WSock.SendData "USER " & Username1 & vbCrLf
output = output & "USER " & Username1 & vbCrLf
ReadLine
WSock.SendData "PASS " & Password1 & vbCrLf
output = output & "PASS " & Password1 & vbCrLf
ReadLine
End Sub
Private Sub GetLast()
Dim InData As String
Dim intTimeOut As Integer
Dim strLastMsg As String
Dim intLastMsg As Integer
WSock.SendData "LAST" & vbCrLf
intTimeOut = 0
InData = ""
Do
intTimeOut = intTimeOut + 1
WSock.GetData InData
If intTimeOut > 12 And InData = "" Then InData = _
"ERROR - Timeout Occured After " & intTimeOut / 2 & " Seconds."
If InData = "" Then Pause (500)
Loop While InData = ""
strLastMsg = Mid$(InData, 4)
intLastMsg = CInt(strLastMsg)
intLastMsg = intLastMsg + 1
output = output & "Getting Message " & intLastMsg & vbCrLf
WSock.SendData "RETR " & intLastMsg & vbCrLf
ReadLine
End Sub
Private Sub Pause(Interval As Long)
Dim Start
Start = GetTickCount
Do While GetTickCount < Start + Interval
DoEvents
Loop
End Sub
-----[End DLL]---------------------------------------------
-----[Begin ASP]-------------------------------------------
<%
dim strOutput, strUser, strPass, strSite, strPort, objMailDll
set objMailDll = Server.CreateObject("AspConx.Mail"
strUser = Request.Form("Username"
strPass = Request.Form("Password"
strSite = Request.Form("Site"
strPort = Request.Form("Port"
strOutput = objMailDll.GetMyMail(strUser, strPass, strSite, strPort)
response.Write strOutput & "<br>"
set objMailDll = Nothing
%>
-----[End ASP]---------------------------------------------