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

Postie

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

Simple Email Reader


DirChange("c:\temp\email")

AddExtender("WWPST34I.DLL")
host="mail.yourdomain.com"
fromaddr=""
userid="metro"
password="halfdollar"
port=""
msgnumber=""
extractfile=""
mailbox=""
flags=""


kInit(host,fromaddr,userid,password,port)
allmsgs=kGetMail(msgnumber,extractfile,"",mailbox,flags)


xmsgs=ItemExtract(3,allmsgs," ")
if !isNumber(xmsgs)
	Message("Error",allmsgs)
	exit
endif

xpos=0
For i=1 to xmsgs
   ;Grab Message Contents
   xpos=StrIndex(allmsgs,"Date:",xpos,@fwdscan)
   temppos=StrIndex(allmsgs,@CRLF,xpos,@backscan)
   temppos=StrIndex(allmsgs,@CRLF,temppos,@backscan)+2
   ; advance the pointer to just past the current "date" 
   ; so as to search forward to next date
   nextdatepos=StrIndex(allmsgs,"Date:",xpos+1,@fwdscan)
   nextpos=StrIndex(allmsgs,@crlf,nextdatepos,@backscan)
   nextpos=StrIndex(allmsgs,@crlf,nextpos,@backscan)+2
   msgcontent=StrSub(allmsgs,temppos,nextpos-temppos)

	;Replace @LF with @CRLF
   bb = BinaryAlloc(StrLen(msgcontent)*2)
	BinaryPokestr(bb,0,msgcontent)
	BinaryReplace(bb,@LF,@CRLF,@True)
	msgcontent = BinaryPeekstr(bb,0,BinaryEODGet(bb))


	;Check for attachment
	attachment = ""
	attachpos = StrIndex(allmsgs,"Attachment:",xpos,@fwdscan)
	if attachpos != 0 
		crlfpos = StrIndex(allmsgs,"(",attachpos,@fwdscan)
		attachpos = attachpos+12
		attachment = StrSub(allmsgs,attachpos,crlfpos-attachpos)
		attachment = StrTrim(attachment)
   endif

	;Display message to user
	MyDialogFormat=`WWWDLGED,6.1`

	MyDialogCaption=`WIL Dialog 1`
	MyDialogX=002
	MyDialogY=050
	MyDialogWidth=408
	MyDialogHeight=259
	MyDialogNumControls=005
	MyDialogProcedure=`DEFAULT`
	MyDialogFont=`DEFAULT`
	MyDialogTextColor=`DEFAULT`
	MyDialogBackground=`DEFAULT,DEFAULT`
	MyDialogConfig=0
	
	MyDialog001=`122,234,051,011,PUSHBUTTON,DEFAULT,"Do Something",2,2,32,DEFAULT,DEFAULT,DEFAULT`
	MyDialog002=`204,234,067,011,PUSHBUTTON,DEFAULT,"Do Nothing",1,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
	MyDialog003=`009,020,374,166,MULTILINEBOX,msgcontent,"",DEFAULT,3,8,DEFAULT,DEFAULT,DEFAULT`
	MyDialog004=`055,196,328,011,VARYTEXT,attachment,"",DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
	MyDialog005=`009,196,041,011,STATICTEXT,DEFAULT,"Attachment:",DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
	
	ButtonPushed=Dialog("MyDialog")
	
	;check which button was pressed
	Switch ButtonPushed
    case 1
        editor = Message("User chose:","Do nothing")
        break
    case 2
        editor = Message("User chose:","Do something")
        break
	endswitch

	 ;move pointer to next message
	 xpos=nextpos-1
Next

Article ID:   W16351
File Created: 2005:02:18:12:19:58
Last Updated: 2005:02:18:12:19:58