$include "rapidq.inc"
$typecheck on
declare sub loadmail
declare sub exitme
declare sub aboutme
declare sub readdata (h as integer)
' Copy and paste into your program
CREATE Form AS QFORM
Caption = "POP3-Mail-Client"
Width = 421
Height = 421
Center
CREATE Main as Qmainmenu
CREATE ende as Qmenuitem
caption = "Beenden"
onclick = exitme
end create
CREATE about as qmenuitem
caption = "Über das Program"
onclick = aboutme
end CREATE
end create
CREATE Label1 AS QLABEL
Caption = "Server:"
Left = 10
Top = 25
Width = 43
Height = 17
Transparent = 1
END CREATE
CREATE Label2 AS QLABEL
Caption = "Username:"
Left = 10
Top = 50
Width = 50
Height = 19
Transparent = 1
END CREATE
CREATE Label3 AS QLABEL
Caption = "Password:"
Left = 10
Top = 75
Width = 50
Height = 19
Transparent = 1
END CREATE
CREATE Label4 AS QLABEL
Caption = "Server-"+chr$(13)+"Output:"
Left = 10
Top = 108
Transparent = 1
Wordwrap = True
END CREATE
CREATE Label5 AS QLABEL
Caption = "Message:"
Left = 10
Top = 190
Width = 50
Transparent = 1
END CREATE
CREATE Edit1 AS QEDIT
Text = "localhost"
Left = 70
Width = 300
Top = 25
END CREATE
CREATE Edit2 AS QEDIT
Text = "ts"
Left = 70
Width = 300
Top = 50
TabOrder = 1
END CREATE
CREATE Edit3 AS QEDIT
Text = "xxxxxxxx"
Left = 70
Width = 300
Top = 75
TabOrder = 2
END CREATE
CREATE ListBox1 AS QLISTBOX
Left = 70
Top = 108
Width = 322
Height = 71
TabOrder = 3
END CREATE
CREATE ListBox2 AS QRICHEDIT 'QLISTBOX
Left = 71
Top = 190
Width = 322
TabOrder = 4
END CREATE
CREATE Button1 AS QBUTTON
Caption = "Abruf"
Left = 10
Top = 308
Width = 383
TabOrder = 5
OnClick = loadmail
END CREATE
CREATE StatusBar1 AS QSTATUSBAR
Addpanels "Status: Waiting for User Interaction"
END CREATE
END CREATE
'Insert your initialization code here
TYPE Conf
IP as string * 13
ID as string * 2
end type
dim Config as Conf
dim timem as qtimer
timem.interval = (1000*60*15)
timem.ontimer = loadmail
timem.enabled = True
Form.ShowModal
sub loadmail
timem.enabled = False
dim sock as qsocket
dim sn as integer
dim temp as string
dim tnum as integer
dim i as integer
statusbar1.panel(0).caption ="Status: Connecting to "+edit1.text
sn = sock.connect(edit1.text, 110)
if sn < 0 then
showmessage ("Cannot connect to server, check the address and/or try again later")
statusbar1.panel(0).caption ="Status: Waiting for User Interaction"
timem.enabled = True
exit sub
end if
statusbar1.panel(0).caption ="Status: Connection established"
listbox1.additems (sock.readline(sn))
statusbar1.panel(0).caption ="Status: Logging in..."
sock.writeline (sn, "USER "+edit2.text)
temp = sock.readline(sn)
if left$(temp, 4) = "-ERR" then
showmessage ("A serious error has occured:"+chr$(13)+temp)
sock.close(sn)
statusbar1.panel(0).caption ="Status: Awaiting User Interaction"
timem.enabled = True
exit sub
end if
listbox1.additems temp
sock.writeline (sn, "PASS "+edit3.text)
temp = sock.readline(sn)
if left$(temp, 4) = "-ERR" then
showmessage ("A serious error has occured:"+chr$(13)+temp)
sock.close(sn)
statusbar1.panel(0).caption ="Status: Awaiting User Interaction"
timem.enabled = True
exit sub
end if
listbox1.additems temp
statusbar1.panel(0).caption ="Status: Checking Mailbox for contents..."
sock.writeline (sn, "STAT")
temp = sock.readline(sn)
if left$(temp, 4) = "-ERR" then
showmessage ("A serious error has occured:"+chr$(13)+temp)
sock.close(sn)
statusbar1.panel(0).caption ="Status: Awaiting User Interaction"
timem.enabled = True
exit sub
end if
listbox1.additems temp
if left$(temp, 5)="+OK 0" then
showmessage ("Keine neuen Nachrichten!")
statusbar1.panel(0).caption ="Status: Logging out..."
sock.writeline(sn,"NOOP")
listbox1.additems sock.readline(sn)
sock.writeline(sn,"QUIT")
listbox1.additems sock.readline(sn)
sock.close(sn)
statusbar1.panel(0).caption ="Status: Waiting for User Interaction"
timem.enabled = True
exit sub
end if
temp = right$(temp, len(temp)-4)
tnum = INSTR(temp, " ")
tnum = val(mid$(temp, 1, tnum-1))
listbox2.text = "Nachrichten:"+chr$(13)+chr$(10)
for i = 1 to tnum
sock.writeline (sn, "RETR "+str$(i))
temp = sock.readline(sn)
if left$(temp, 4) = "-ERR" then
showmessage ("A serious error has occured:"+chr$(13)+temp)
sock.close(sn)
statusbar1.panel(0).caption ="Status: Awaiting User Interaction"
timem.enabled = True
exit sub
end if
statusbar1.panel(0).caption ="Status: Retrieving Mail Nr. "+str$(i)
listbox2.text = listbox2.text + chr$(13)+chr$(10)+"Nachricht Nr. "+str$(i)+ ":"+chr$(13)+chr$(10)
readdata(sn)
next i
'Deleting the mails
for i = 1 to tnum
sock.writeline (sn, "DELE 1")
temp = sock.readline(sn)
if left$(temp, 4) = "-ERR" then
showmessage ("A serious error has occured:"+chr$(13)+temp)
sock.close(sn)
statusbar1.panel(0).caption ="Status: Awaiting User Interaction"
exit sub
end if
statusbar1.panel(0).caption ="Status: Deleting Mail Nr. "+str$(i)
next i
'Logging out here...
statusbar1.panel(0).caption ="Status: Logging out..."
sock.writeline(sn,"NOOP")
listbox1.additems sock.readline(sn)
sock.writeline(sn,"QUIT")
listbox1.additems sock.readline(sn)
sock.close(sn)
statusbar1.panel(0).caption ="Status: Waiting for User Interaction"
timem.enabled = True
end sub
sub readdata (h as integer)
dim so as qsocket
do
listbox2.text=listbox2.text+ so.readline(h)
loop until so.IsServerReady(h)=False
end sub
sub exitme
form.close
end
end sub
sub aboutme
showmessage ("This Program has been written by Andreas Fink, Archivzivi "+chr$(13)+"from august 1999 to june 2000")
end sub