Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Name/Address Parsing Outlook OOP-Style

Automation

Name/Address Parsing Outlook OOP-Style

by  craigsboyd  Posted    (Edited  )
Cut & Paste the code below into a PRG in VFP and execute it to see this run. - Craig Boyd

Code:
**********************************************
*
*    Sample code using clsOutlookParser
*
**********************************************
CLEAR

LOCAL loParser
loParser = CREATEOBJECT("clsOutlookParser")

loParser.FullName = "Dr. William T. Van Essen Sr."
loParser.Address = "315 SW 3rd Street" + CHR(13) + "Pipestone, MN 56164"
? "Title: " + loParser.Title
? "First Name: " + loParser.FirstName
? "Middle Name: " + loParser.MiddleName
? "Last Name: " + loParser.LastName
? "Suffix Name: " + loParser.Suffix
? "Last Comma First: " + loParser.LastNameAndFirstName
? "Initials: " + loParser.Initials
? "Street: " + loParser.Street
? "PostOfficeBox: " + loParser.PostOfficeBox
? "City: " + loParser.City
? "State: " + loParser.State
? "PostalCode: " + loParser.PostalCode
? "Country: " + loParser.Country
?

loParser.FullName = "Mrs. Bellenton, Susan Elizabeth"
loParser.Address = "315 SW 3rd Street" + CHR(13) + "Pipestone, MN 56164"
? "Title: " + loParser.Title
? "First Name: " + loParser.FirstName
? "Middle Name: " + loParser.MiddleName
? "Last Name: " + loParser.LastName
? "Suffix Name: " + loParser.Suffix
? "Last Comma First: " + loParser.LastNameAndFirstName
? "Initials: " + loParser.Initials
? "Street: " + loParser.Street
? "City: " + loParser.City
? "State: " + loParser.State
? "PostalCode: " + loParser.PostalCode
? "Country: " + loParser.Country
?

**********************************************
DEFINE CLASS clsOutlookParser as custom
**********************************************

    FullName = ""
    Title = ""
    FirstName = ""
    LastName = ""
    MiddleName = ""
    Suffix = ""
    LastNameAndFirstName = ""
    Initials = ""
    Address = ""
    Street = ""
    PostOfficeBox = ""
    City = ""
    State = ""
    PostalCode = ""
    Country = ""
    OutlookApp = NULL
    ContactItem = NULL
        
    PROCEDURE init
        this.OutlookApp = CreateObject("Outlook.Application")
        this.ContactItem = this.OutlookApp.CreateItem(2) && 2 = Contact Item
    ENDPROC
    
    PROCEDURE FullName_Assign
        LPARAMETERS m.vNewVal
        this.ContactItem.FullName = m.vNewVal
    ENDPROC
    
    PROCEDURE FullName_Access
        RETURN this.ContactItem.FullName
    ENDPROC
    
    PROCEDURE Title_Access
        RETURN this.ContactItem.Title
    ENDPROC
    
    PROCEDURE FirstName_Access
        RETURN this.ContactItem.FirstName
    ENDPROC
    
    PROCEDURE MiddleName_Access
        RETURN this.ContactItem.MiddleName
    ENDPROC
    
    PROCEDURE LastName_Access
        RETURN this.ContactItem.LastName
    ENDPROC
    
    PROCEDURE Suffix_Access
        RETURN this.ContactItem.Suffix
    ENDPROC

    PROCEDURE LastNameAndFirstName_Access
        RETURN this.ContactItem.LastNameAndFirstName
    ENDPROC

    PROCEDURE Initials_Access
        RETURN this.ContactItem.Initials
    ENDPROC

    PROCEDURE Address_Assign
        LPARAMETERS m.vNewVal
        this.ContactItem.OtherAddress = m.vNewVal
    ENDPROC
    
    PROCEDURE Address_Access
        RETURN this.ContactItem.OtherAddress
    ENDPROC

    PROCEDURE Street_Access
        RETURN this.ContactItem.OtherAddressStreet
    ENDPROC

    PROCEDURE City_Access
        RETURN this.ContactItem.OtherAddressCity
    ENDPROC

    PROCEDURE State_Access
        RETURN this.ContactItem.OtherAddressState
    ENDPROC

    PROCEDURE PostalCode_Access
        RETURN this.ContactItem.OtherAddressPostalCode
    ENDPROC

    PROCEDURE Country_Access
        RETURN this.ContactItem.OtherAddressCountry
    ENDPROC
    
    PROCEDURE Destroy
        this.ContactItem.Close(1) && 1 = Discard
        this.OutlookApp.Quit()
        this.ContactItem = NULL
        this.OutlookApp = NULL
    ENDPROC
    
ENDDEFINE && clsOutlookParser
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top