I need to retrieve the subject and date stamp ONLY of any mail on my
POP3 server. The last version of the Atomic mailer I had is very old,
and only lets you retrieve the entire mail, not just the subject/date.
Here it is... does anyone know how to modify it to achieve my goal?
It's probaby really simple, but I just can't work it out right now.
Code: Select all
InitNetwork()
OpenConsole()
#MODE_Authorization = 1
#MODE_Transaction = 2
Login$ = "login"
Password$ = "password"
POP_Provider$ = "pop.mailserver.com.au"
EOL$ = Chr(13)+Chr(10)
Pop3Mode = #MODE_AUTHORIZATION
NetWorkID=OpenNetworkConnection(POP_Provider$, 110)
If NetWorkID0
PrintN("Connected..")
AllocateMemory(0, 2000, 0)
Repeat
NEvent = NetworkClientEvent(NetWorkID)
If NEvent
ReadLength = ReceiveNetworkData(NetWorkID, UseMemory(0), 2000)
If (ReadLength) > 2
PokeB(UseMemory(0)+ReadLength-2, 0) ; Remove the CRLF directly
Line$ = PeekS(UseMemory(0))
PrintN(Line$)
Gosub ParseLine
Else
PrintN("Bad received packet")
EndIf
Else
Delay(20)
EndIf
ForEver
Else
PrintN("Impossible to connect to the pop3 the server")
EndIf
MessageRequester("Info", "Program finished correctly.", 0)
End
ParseLine:
If Len(Line$) >= 3
If Left(Line$, 3) = "+OK"
Select Pop3Mode
Case #MODE_Authorization
Gosub Authorization
Case #MODE_Transaction
Gosub Transaction
Default
; PrintN("Error: no such case 1")
EndSelect
Else
; PrintN("Error... Deconnect now ! (-ERR)");
EndIf
Else
; PrintN("Error... Too short packet");
EndIf
Return
; Authorization
the init phase where the user must login..
;
;
Authorization:
Select AuthStep
Case 0
a$ = "USER "+Login$+EOL$
SendNetworkData(NetWorkID, a$, Len(a$))
Case 1
a$ = "PASS "+Password$+EOL$
SendNetworkData(NetWorkID, a$, Len(a$))
Pop3Mode = #MODE_Transaction
;Case 2
; a$ = "QUIT"+EOL$
; SendNetworkData(0, a$, Len(a$))
; Pop3Mode = #MODE_Transaction
EndSelect
AuthStep+1
Return
Transaction:
Select TransStep
Case 0
a$ = "STAT"+EOL$
SendNetworkData(NetWorkID, a$, Len(a$))
Case 1
a$ = "LIST "+EOL$
SendNetworkData(NetWorkID, a$, Len(a$))
Case 2
PrintN("Type msg# to retreive:")
Nb$ = Input()
PrintN(Str(1100))
PrintN("Retrieving...")
; Nb$ = "1"
a$ = "RETR "+Nb$+EOL$
SendNetworkData(NetWorkID, a$, Len(a$))
TransStep-1
If CreateFile(0, "MAIL.txt")
FirstTime = 1
Size = 1
Repeat
NEvent = NetworkClientEvent(NetWorkID)
If NEvent
ReadLength = ReceiveNetworkData(NetWorkID, UseMemory(0), 1999)
PokeB(UseMemory(0)+ReadLength, 0)
a$ = PeekS(UseMemory(0))
PrintN(a$)
If FirstTime
Position = FindString(a$, " ", 5)
Size$ = Mid(a$, 5, Position-5)
PrintN(Size$)
Size = Val(Size$)
FirstTime = 0
WriteString(a$)
Size-ReadLength
Else
WriteString(a$)
Size-ReadLength
EndIf
Else
Delay(20)
EndIf
Until Size <= 0 ; And FirstTime = 0
CloseFile(0)
PrintN("Mail transfer finished")
Else
PrintN("Can't open the file...")
EndIf
EndSelect
TransStep+1
Return