PDA

Click to See Complete Forum and Search --> : SMTP - Quite Urgent


lenin
Dec 6th, 1999, 02:20 PM
Hello,
I have a small mail app which uses the winsock control to attach to the SMTP port of my local exchange server, however I need to use the actual winsock cotrol. Is there any way of using the winsock.dll directly, so perhaps I could create a customised mail class with code only?

Like

dim newWin as winsock
set newWin = New winsock

newWin.connect .....


Thanks in advance.

Dec 6th, 1999, 09:07 PM
Add a REFERENCE(not as component) to Mswinsck.ocx

This is when you would just use a module.
You could also use a class and call that from the module then you could use the default events you also get with the control
Private WithEvents sckTest As MSWinsockLib.Winsock

But here a simple example

Option Explicit
'Add a REFERENCE(not as component) to Mswinsck.ocx (%winsysdir%\Mswinsck.ocx)
Private sckTest As MSWinsockLib.Winsock

Sub Main()
Dim sData As String
Dim sBuffer As String

Set sckTest = New Winsock
sckTest.Connect "[My SMTP Server]", 25
Do Until sckTest.State = sckConnected And Not sckTest.State = sckError
DoEvents
Loop
If sckTest.State = sckError Then 'Error
End
End If
Do
sckTest.PeekData sBuffer, vbString
If sBuffer <> "" Then
sckTest.GetData sBuffer, vbString
End If
sData = sData & sBuffer
Debug.Print sData
'Proccess data here

'Finishd data proccssing
DoEvents
Loop
End Sub


Hope it helps.
(Use edit message to copy the code.)

------------------

Vincent van den Braken
EMail: azzmodan@azzmodan.demon.nl
ICQ: 15440110 (http://www.icq.com/15440110)
Homepage: http://www.azzmodan.demon.nl



[This message has been edited by Azzmodan (edited 12-07-1999).]

[This message has been edited by Azzmodan (edited 12-07-1999).]

lenin
Dec 6th, 1999, 09:17 PM
This looks like exactly what I want, many thanks.

Tony.