WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Examples

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

MAIL SCANNER SAMPLE WINSOCK APP

Keywords:  scan mailbox mail server e-mail email  

;**************************************************************************
;		 MAIL SCANNER SAMPLE WINSOCK APP
;
; Usage: Run this file from WinBatch, optionally with 2 params:
;	 WILScanMail.WBT "<your dialup name>" "<your mail server>"
;
; Author: Jennifer Palonus (GDI)
; 
;  Date	   Major changes
; -------  ----------------------------------------------------------------
; 01apr96  Cloned from WILMail.wbt.
; 30apr96  
;**************************************************************************

sTitle = "WILScanMail"
sDial = "%param1%"
edMailServer = "%param2%"
sPort = "pop3"


AddExtender ("wwwsk34I.dll")


;Dial our host, asking first if user has more than 1 defined...
hConn = 0
sDialUps = DUNItemize ()
if (ItemCount(sDialUps,@TAB) == 1)
	sDial = sDialUps
else
	sDial = AskItemList ("Choose a dial-up connection", sDialUps, @TAB, @SORTED, @SINGLE)
endif

hConn = DUNConnect (sDial)
nErr = wxGetLastErr()
if (!hConn)
	select (nErr)
		case @SErrBusy
			Message (sTitle, "Couldn't connect to %sDial%: Line busy.")
			break
		case @SErrNoAnswer
			Message (sTitle, "Couldn't connect to %sDial%: No answer.")
			break
		case @SErrVoice
			Message (sTitle, "Couldn't connect to %sDial%: A human answered.")
			break
		case nErr
			Message (sTitle, "Couldn't connect to %sDial%: Error %nErr%.")
	end select
	exit
endif


; Get information & log on...
hPOP = 0
while (!hPOP)
	; Get our mail server, etc...
	dlgScanMailFormat=`WWWDLGED,5.0`
	dlgScanMailCaption=`ScanMail`
	dlgScanMailX=52
	dlgScanMailY=70
	dlgScanMailWidth=143
	dlgScanMailHeight=65
	dlgScanMailNumControls=8
	dlgScanMail01=`8,0,64,DEFAULT,STATICTEXT,DEFAULT,"Your mail server:"`
	dlgScanMail02=`72,0,64,DEFAULT,EDITBOX,edMailServer,""`
	dlgScanMail03=`8,12,64,DEFAULT,STATICTEXT,DEFAULT,"User name:"`
	dlgScanMail04=`72,12,64,DEFAULT,EDITBOX,edUser,""`
	dlgScanMail05=`8,24,64,DEFAULT,STATICTEXT,DEFAULT,"Password:"`
	dlgScanMail06=`72,24,64,DEFAULT,EDITBOX,PW_PW,""`
	dlgScanMail07=`14,44,54,DEFAULT,PUSHBUTTON,DEFAULT,"OK",1`
	dlgScanMail08=`72,44,54,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",2`

	nRet=Dialog("dlgScanMail")
	if (nRet == 2)
		goto HangUp
	endif


	hPOP = P3Open (edMailServer, edUser, PW_PW);
	if (!hPOP)
		sReply = P3GetReply()
		Message (sTitle, `Couldn't open a POP3 session.%CRLF%Server replied: %sReply%`)
	endif
endwhile


; Walk thru the messages in the inbox...
nMsgs = P3Count (hPOP)
for nMsg = 1 to nMsgs
	sMsgText = P3Peek (hPOP, nMsg, 5)

	nErr = wxGetLastErr()
	select nErr
		case @P3ErrReply
			sReply = P3GetReply()
			Message (sTitle, "Mail server gave error reply to peek request: %sReply%")
			break

		case @SOK
			Message ("Message %nMsg%", sMsgText)
			break

		case nErr
			Message (sTitle, "Error %nErr% peeking at message!")
			break
	end select
next nMsg

P3Close (hPOP)

Message (sTitle, "Scanned %nMsgs% messages to %edUser%.")


; User hit Cancel...
:Cancel

; Hang up...
:HangUp
if (hConn)
	nRet = DUNDisconnect (hConn)
endif

exit




Article ID:   W12636
Filename:   Mailbox Scanner.txt
File Created: 2001:03:01:15:11:34
Last Updated: 2001:03:01:15:11:34