Hey, thanx to all the guys in here, i have done some code for retrieving email messages from a pop3 server. this is just a part of my new project. i just put it here so people can see what to do and not to fall into stupid traps i fell in. so here it goes.
1. in a module, create these enums and types.
VB Code:
Public Enum POP_STATUS 'this is for the status of the pop getter pop_Connect pop_User pop_Password pop_Stat pop_List pop_Retr pop_CRetr pop_Delete pop_Quit End Enum Public Type MSG_STATS 'this is for the messages in the server msg_Len As Long msg_ThisLen As Long msg_Body As String msg_File As String End Type Public Type POP_SERVER 'this is for the pop server settings srv_Name As String srv_Address As String srv_Port As Long srv_User As String srv_Password As String srv_Messages As Long End Type
then there are some variable declarations, name it whatever u want but here is what i have done.
VB Code:
Public pStat As POP_STATUS Public myMsg() As MSG_STATS Public myServer As POP_SERVER Public mError As Long Public curMsg As Long Public myMsgList As String Public myMsgListNum As Long Public fso As New FileSystemObject' use this if u want to save data using the file system objects, or omit the 2 lines here. Public ***ile As TextStream
now for the settings part, as we already have some settings put up as a datatype, we will access it here.
VB Code:
With myServer .srv_Address = "<your pop3 server>" .srv_Name = "<Name of your ISP, not needed explicitly>" .srv_User = "<your pop3 username>" .srv_Password = "<your pop3 password>" .srv_Port = 110 'this is the default pop3 port. End With
and then the connection part. u know the drill
VB Code:
pStat = pop_Connect 'we set the status enum to connecting stage With myServer ws.Connect .srv_Address, .srv_Port End With




Reply With Quote