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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

winsock and email woes....

Status
Not open for further replies.

fenris

Programmer
May 20, 1999
824
CA
I have a simple question. I have written a program that uses the winsock control to conect to a pop3 server and allows the user to list, read and delete email messages. The problem that I am having is splitting up the data that is comming back from the winsock Dataarrival event.

It works fine, eccept that all the information gets funneled into the same textbox and i can not figure out a easy way to separate email messages into another text box.

Basically when the List command is issued to the pop3 server, I went the resultant list of waiting mail messages to be directed to another text box, and likewise for the email messages....

Does anybody have any ideas?





Troy Williams B.Eng.
fenris@hotmail.com

 
Sounds like you need to do some string manipulation on the string you get back to manually fill the listbox or something like that.

I would be very interested in how you are working with the winsock control to access a pop server, as I am forced to work with MAPI, which whilst simple limits functionality severely. If possible, I would appreciate a glimpse of your code.

Thanks

Coffee
 
Coffee, here is what I have so far....


'A snippet of the winsock stuff
'=============================
Private Sub connect() 'a sub that is called from one of the command buttons
'mailsock is the winsock control on the form
MailSock.Protocol = sckTCPProtocol
MailSock.RemotePort = 110 'default connect port
MailSock.RemoteHost = popServer 'popserver is a string holding the name of the pop3 server

MailSock.Close 'close all open connections
MailSock.connect 'Establish connection

'addtext simply adds text to text box
addText "** Connecting to " + popServer + " **", txtStatus
End Sub

Private Sub MailSock_Connect()

addText "** Connection accepted **", txtStatus
MailSock.SendData "USER " + userName + vbCrLf
addText userName + " -> USER " + userName, txtStatus
MailSock.SendData "PASS " + password + vbCrLf
addText userName + " -> PASS (password)", txtStatus
MailSock.SendData "STAT" + vbCrLf
addText userName + " -> STAT", txtStatus
End Sub



Public Sub disconnect()
If MailSock.State <> sckClosed Then
MailSock.Close
End If
End
End Sub

Private Sub MailSock_Close()
addText &quot;** Connection Closed **&quot;, txtStatus
End Sub


Private Sub MailSock_DataArrival(ByVal bytesTotal As Long)
Dim indata As String

MailSock.GetData indata, vbString
addText popServer + &quot; -> &quot; + indata, txtStatus

End Sub



Private Sub addText(msg As String, txt As TextBox)
txt.Text = txt.Text + msg + vbNewLine
End Sub
'=============================


The snippet should give you a good idea of how to connect to a pop3 server. I wrote it this way to allow myself to see what was going on in the background!

Good Luck....



Troy Williams B.Eng.
fenris@hotmail.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top