Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: mailbox email e-mail scan mailbox read mailbox forms
;************************************************************************** ; WEB FORM RESPONSE SCANNER SAMPLE WINSOCK APP ; ; This sample app will scan your mailbox for messages sent to it from a ; form on your web page. Here's how to use it: ; ; 1) Create a form on your web page using METHOD=POST and ; ACTION="mailto:yourname@yourisp.com". ; ; 2) Fill out the form a few times. Each time a caller fills out such a ; form, their web browser posts a one-line mail message to your mailbox ; with a MIME type of "application/x-www-form-urlencoded". ; ; 3) Run this file from WinBatch, optionally with 2 params: ; ScanForm.WBT "<your dialup name>" "<your mail server>" ; ; 4) This script will examine each message in your mailbox. For each one ; with the proper MIME type, it will take the message body and split it ; up into its component parts. Each part is Fieldname=value. The script ; will ignore any messages that don't have the proper MIME type. ; ; 5) To use this script in a real-world situation, you probably would call ; P3Delete() on each form-response message after it gets processed. ; ; ; Author: Jennifer Palonus (GDI) ; ; Date Major changes ; ------- ---------------------------------------------------------------- ; 05apr96 Cloned from WILScanMail.wbt. ; 30apr96 ;************************************************************************** sTitle = "ScanForm" sDial = "%param1%" edMailServer = "%param2%" 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=150 dlgScanMailHeight=72 dlgScanMailNumControls=8 dlgScanMail01=`8,4,64,DEFAULT,STATICTEXT,DEFAULT,"Your mail server:"` dlgScanMail02=`72,4,64,DEFAULT,EDITBOX,edMailServer,""` dlgScanMail03=`8,16,64,DEFAULT,STATICTEXT,DEFAULT,"User name:"` dlgScanMail04=`72,16,64,DEFAULT,EDITBOX,edUser,""` dlgScanMail05=`8,28,64,DEFAULT,STATICTEXT,DEFAULT,"Password:"` dlgScanMail06=`72,28,64,DEFAULT,EDITBOX,PW_PW,""` dlgScanMail07=`14,48,54,DEFAULT,PUSHBUTTON,DEFAULT,"OK",1` dlgScanMail08=`72,48,54,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",2` nRet=Dialog("dlgScanMail") if (nRet == 2) goto HangUp endif hPOP = P3Open (edMailServer, edUser, PW_PW); if (!hPOP) nErr = wxGetLastErr() select nErr case @P3ErrReply sReply = P3GetReply() Message (sTitle, `Couldn't open a POP3 session.%CRLF%Server replied: %sReply%`) break case nErr Message (sTitle, "Error %nErr% opening POP3 session.") break endselect endif endwhile if (!hPOP) goto HangUp endif ; Walk thru the messages in the inbox... nMsgs = P3Count (hPOP) nForms = 0 for nMsg = 1 to nMsgs sMsgText = P3RecvText (hPOP, nMsg, 32767) nErr = wxGetLastErr() select nErr case @P3ErrReply sReply = P3GetReply() Message (sTitle, "Mail server gave error reply to RETRieve request: %sReply%") break case @SOK gosub ParseMessage break case nErr Message (sTitle, "Error %nErr% downloading message!") break endselect next nMsg P3Close (hPOP) Message (sTitle, "Processed %nForms% forms out of %nMsgs% messages.") ; User hit Cancel... :Cancel ; Hang up... :HangUp if (hConn) nRet = DUNDisconnect (hConn) endif exit ;************************************************************************** ; We've read a message from our mailbox into sMsgText. See if it's from a ; Web form & process it. ;************************************************************************** :ParseMessage if (strindex (sMsgText, "application/x-www-form-urlencoded", 1, @FWDSCAN) == 0) return endif nForms = nForms + 1 ; The message is a web form response. Parse it... nBOL = 1 while (nBOL > 0) nEOL = strindex (sMsgText, @CRLF, nBOL, @FWDSCAN) sLine = strsub (sMsgText, nBOL, nEOL-nBOL) nBOL = nEOL + 2 ; sMsg = strcat ("Line = ", sLine) ; Message (sTitle, sMsg) if (sLine == "") ; We found the null line separating a msg header from the body... nEOL = strindex (sMsgText, @CRLF, nBOL, @FWDSCAN) sLine = strsub (sMsgText, nBOL, nEOL-nBOL) break endif endwhile ; sLine is now the first line of the message body, which should be the form ; responses, urlencoded... sLine = URLDecode (sLine) sMsg = strcat ("Cleaned up = ", sLine) Message (sTitle, sMsg) gosub ProcessFormResponse return ;************************************************************************** ; This message is a "POST" form response. Do something with it. ;************************************************************************** :ProcessFormResponse AskItemList ("These are the responses to this form:", sLine, "&", @SORTED, @SINGLE); ;P3Delete (hPOP, nMsg) ;nErr = wxGetLastErr() ;if (nErr == @P3ErrReply) ; sReply = P3GetReply() ; Message (sTitle, "Couldn't delete the message: %sReply%") ;endif return
Article ID: W12637
Filename: Process Form Response in Mailbox.txt
File Created: 2001:03:01:15:11:44
Last Updated: 2001:03:01:15:11:44