Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I've Got The ASP DLL WinSock POP3 Blues

Status
Not open for further replies.

LCD

MIS
Feb 19, 2001
72
0
0
US
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 & &quot;Error Connecting To Server - Case 9<br>&quot;
Case 8
output = output & &quot;Error Connecting To Server - Case 8<br>&quot;
Case 7
output = output & &quot;Connected To Server!&quot; & vbCrLf
ReadLine
Login
GetLast
.SendData &quot;Quit&quot; & vbCrLf
Pause (500)
End Select
End With
GetMyMail = &quot;<textarea name=&quot;&quot;txtarea&quot;&quot; rows=&quot;&quot;25&quot;&quot; cols=&quot;&quot;80&quot;&quot;>&quot; _
& output & &quot;</textarea><br>&quot;
End Function


Private Sub ReadLine()
Dim InData As String
Dim intTimeOut As Integer
intTimeOut = 0
InData = &quot;&quot;
Do
intTimeOut = intTimeOut + 1
WSock.GetData InData
If intTimeOut > 12 And InData = &quot;&quot; Then InData = _
&quot;ERROR - Timeout Occured After &quot; & intTimeOut / 2 & &quot; Seconds.&quot;
If InData = &quot;&quot; Then Pause (500)
Loop While InData = &quot;&quot;
output = output & InData & vbCrLf
End Sub


Private Sub Login()
WSock.SendData &quot;USER &quot; & Username1 & vbCrLf
output = output & &quot;USER &quot; & Username1 & vbCrLf
ReadLine
WSock.SendData &quot;PASS &quot; & Password1 & vbCrLf
output = output & &quot;PASS &quot; & 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 &quot;LAST&quot; & vbCrLf
intTimeOut = 0
InData = &quot;&quot;
Do
intTimeOut = intTimeOut + 1
WSock.GetData InData
If intTimeOut > 12 And InData = &quot;&quot; Then InData = _
&quot;ERROR - Timeout Occured After &quot; & intTimeOut / 2 & &quot; Seconds.&quot;
If InData = &quot;&quot; Then Pause (500)
Loop While InData = &quot;&quot;
strLastMsg = Mid$(InData, 4)
intLastMsg = CInt(strLastMsg)
intLastMsg = intLastMsg + 1
output = output & &quot;Getting Message &quot; & intLastMsg & vbCrLf
WSock.SendData &quot;RETR &quot; & 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(&quot;AspConx.Mail&quot;)
strUser = Request.Form(&quot;Username&quot;)
strPass = Request.Form(&quot;Password&quot;)
strSite = Request.Form(&quot;Site&quot;)
strPort = Request.Form(&quot;Port&quot;)
strOutput = objMailDll.GetMyMail(strUser, strPass, strSite, strPort)
response.Write strOutput & &quot;<br>&quot;
set objMailDll = Nothing
%>

-----[End ASP]---------------------------------------------
 
Use Package and deployment wizard to create a cabfile for destination server. Note if you have not registerd the Dll on the server you cannot execute Server.CreateObject(&quot;AspConx.Mail&quot;). You might consider creating a quick and dirty test harness (testMeAspConx.exe )that you use to verify the viability of your activex on destination server. This may help you identify missing dll's needed with your's/version problems etc. Asp errors are not extremely helpful on activex,dlls issues.
 
Cyclopsz,
I initialy installed using Package and Deployment, after the first error, I ran &quot;regsvr32.exe AspConx.dll&quot; to manualy registered it. But it didn't help. Since then I've also ran depends, and there are no missing dependencies. I made sure security was set properly. I also created another DLL real quick (Just a simple helloworld) and through it in the same folder, and that one worked. So I'm inclined to think it was somthing to do with the use of winsock. Any thoughts? Thanks for the help.

Andrew
 
Winsock requires a form to run on, no? Does your DLL contains forms?
Try playing with the application settings; there should be a &quot;run unattended&quot;. Maybe you should (on your dev machine) try to call it from an app that works as a service.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top