CREATE TABLE Emails (cEmail c(100), iSMTP i, iError i) CREATE TABLE Validator (iBad i, iValue i, iMax i) CREATE TABLE DumbDomains (cDomain c(50)) INDEX ON cDomain TAG cDomain PUBLIC ofrmvalidate SET CLASSLIB TO t:\baseclasses\baseclasses.vcx ADDITIVE ofrmvalidate=NEWOBJECT("frmvalidate") ofrmvalidate.Show RETURN ************************************************** *-- Form: frmvalidate (d:\users\work\visual foxpro projects\email validator\validator.scx) *-- ParentClass: frm (t:\baseclasses\baseclasses.vcx) *-- BaseClass: form *-- Time Stamp: 05/22/03 11:44:14 AM * #INCLUDE "d:\users\work\visual foxpro projects\email validator\validator.h" * DEFINE CLASS frmvalidate AS frm Height = 90 Width = 348 Desktop = .T. ShowWindow = 2 DoCreate = .T. BorderStyle = 1 Caption = "" MaxButton = .F. Icon = "validate.ico" ovalidator = .NULL. Name = "frmValidate" ADD OBJECT tmrcontrol AS timer WITH ; Top = 66, ; Left = 324, ; Height = 23, ; Width = 23, ; Enabled = .F., ; Interval = 100, ; Name = "tmrControl" ADD OBJECT oleprogress AS olecontrol WITH ; Top = 18, ; Left = 24, ; Height = 18, ; Width = 300, ; TabIndex = 1, ; Name = "oleProgress" ADD OBJECT cmgcontrol AS commandgroup WITH ; AutoSize = .T., ; ButtonCount = 3, ; BorderStyle = 0, ; Value = 1, ; Height = 35, ; Left = 150, ; Top = 48, ; Width = 168, ; TabIndex = 3, ; Name = "cmgControl", ; Command1.Top = 5, ; Command1.Left = 5, ; Command1.Height = 25, ; Command1.Width = 50, ; Command1.FontName = "Tahoma", ; Command1.FontSize = 8, ; Command1.Caption = "\<Start", ; Command1.TabIndex = 1, ; Command1.Name = "cmdStart", ; Command2.Top = 5, ; Command2.Left = 59, ; Command2.Height = 25, ; Command2.Width = 50, ; Command2.FontName = "Tahoma", ; Command2.FontSize = 8, ; Command2.Caption = "St\<op", ; Command2.Enabled = .F., ; Command2.TabIndex = 2, ; Command2.Name = "cmdStop", ; Command3.Top = 5, ; Command3.Left = 113, ; Command3.Height = 25, ; Command3.Width = 50, ; Command3.FontName = "Tahoma", ; Command3.FontSize = 8, ; Command3.Caption = "\<Reset", ; Command3.TabIndex = 3, ; Command3.Name = "cmdReset" ADD OBJECT txtbad AS textbox WITH ; FontName = "Tahoma", ; FontSize = 8, ; Alignment = 3, ; Enabled = .F., ; Height = 21, ; InputMask = "999,999", ; Left = 24, ; TabIndex = 2, ; Top = 54, ; Width = 60, ; DisabledForeColor = RGB(0,0,0), ; Name = "txtBad" PROCEDURE setprogress LPARAMETERS tiValue, tiBad WITH This WITH .oleProgress .Value = MIN(tiValue, .Max) liPctg = .Value / .Max * 100 liMax = .Max ENDWITH * Projected bad email addresses .txtBad.Value = IIF(tiBad = 0, tiBad, INT(tiBad / liPctg * 100)) .Caption = ; ALLTRIM(TRANSFORM(tiValue, "999,999")) + " of " + ; ALLTRIM(TRANSFORM(liMax, "999,999")) + " - " + ; ALLTRIM(TRANSFORM(liPctg, "999.9% Complete")) ENDWITH ENDPROC PROCEDURE ovalidator_access WITH This IF ISNULL(.oValidator) .oValidator = CREATEOBJECT("HexValidEmail.Connection") WITH .oValidator .FromDomain = "jeffbowman.com" .FromEmail = "jbowman@jeffbowman.com" ENDWITH ENDIF RETURN .oValidator ENDWITH ENDPROC PROCEDURE dumbdomain LPARAMETERS tcDomain LOCAL ; lcAlias AS String, ; lcEmail AS String lcAlias = LOWER(SUBSTR(SYS(2015), 2) + SYS(2015)) lcEmail = lcAlias + "@" + LOWER(tcDomain) RETURN This.oValidator.Validate(lcEmail, valSMTP) = valSMTP ENDPROC PROCEDURE smtp LPARAMETERS tcEmail AS String, tiError AS Integer LOCAL ; lcDomain AS String, ; lcEmail AS String LOCAL ; liError AS Integer, ; liSMTP AS Integer WITH This lcEmail = LOWER(ALLTRIM(tcEmail)) IF .oValidator.Validate(lcEmail, valSyntax) = valSyntax lcDomain = .oValidator.Domain IF SEEK(lcDomain, "DumbDomains", "cDomain") liSMTP = valSMTP ELSE IF .DumbDomain(lcDomain) INSERT INTO DumbDomains (cDomain) VALUES (lcDomain) liSMTP = valSMTP ELSE liSMTP = .oValidator.Validate(lcEmail, valSMTP) tiError = .oValidator.Error ENDIF ENDIF ELSE liSMTP = valSyntax ENDIF RETURN liSMTP ENDWITH ENDPROC PROCEDURE Init _VFP.AutoYield = False WITH This.oleProgress .Max = RECCOUNT("Emails") REPLACE iMax WITH .Max IN Validator ENDWITH This.SetProgress(Validator.iValue, Validator.iBad) DODEFAULT() ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC PROCEDURE dns ENDPROC PROCEDURE syntax ENDPROC PROCEDURE tmrcontrol.Timer LOCAL ; liRating AS Integer, ; liError AS Integer liError = errSuccess This.Enabled = False IF Validator.iValue = RECCOUNT("Emails") ThisForm.cmgControl.cmdStop.Click() MESSAGEBOX("Processing complete.", icoInformation, "Email Validator") RETURN ELSE GO (Validator.iValue) IN Emails WITH ThisForm liSMTP = .SMTP(Emails.cEmail, @liError) REPLACE ; iSMTP WITH liSMTP, ; iError WITH liError ; IN Emails IF liError = errRecipientRejected REPLACE iBad WITH iBad + 1 IN Validator ENDIF ENDWITH REPLACE iValue WITH iValue + 1 IN Validator ThisForm.SetProgress(Validator.iValue, Validator.iBad) ENDIF This.Enabled = True ENDPROC PROCEDURE cmgcontrol.cmdStart.Click WITH This .Enabled = False WITH .Parent .cmdStop. Enabled = True .cmdReset.Enabled = False ENDWITH ENDWITH WITH ThisForm .tmrControl.Enabled = True .Closable = False ENDWITH ENDPROC PROCEDURE cmgcontrol.cmdStop.Click WITH This .Enabled = False WITH .Parent .cmdStart.Enabled = True .cmdReset.Enabled = True ENDWITH ENDWITH WITH ThisForm .tmrControl.Enabled = False .Closable = True ENDWITH ENDPROC PROCEDURE cmgcontrol.cmdReset.Click LOCAL lcMsg AS String lcMsg = "Are you sure you want to reset the validation scan?" IF MESSAGEBOX(lcMsg, icoQuestion + btnYesNo + btnSecond, "Email Validator") = msgYes REPLACE ; iValue WITH 1, ; iBad WITH 0 ; IN Validator ThisForm.SetProgress(Validator.iValue, Validator.iBad) ENDIF ENDPROC ENDDEFINE * *-- EndDefine: frmvalidate **************************************************>Jeff