Warning: This file has been marked up for HTML
VERSION 4.00
Begin VB.Form frmAddress
BorderStyle = 1 'Fixed Single
Caption = "Address Book Find"
ClientHeight = 6615
ClientLeft = 1095
ClientTop = 1515
ClientWidth = 9390
Height = 7020
Icon = "ABFind.frx":0000
Left = 1035
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 6615
ScaleWidth = 9390
Top = 1170
Width = 9510
Begin VB.ListBox lstFound
Enabled = 0 'False
Height = 3795
IntegralHeight = 0 'False
Left = 7680
TabIndex = 8
Top = 2280
Width = 1575
End
Begin VB.ComboBox cboAddressBooks
Enabled = 0 'False
Height = 315
Left = 120
Style = 2 'Dropdown List
TabIndex = 4
Top = 1620
Width = 9135
End
Begin VB.CommandButton cmdLogin
Caption = "&Login"
Default = -1 'True
Height = 315
Left = 120
TabIndex = 2
Top = 120
Width = 3435
End
Begin VB.TextBox txtParameters
Height = 315
Left = 120
TabIndex = 1
Text = "/ph-"
Top = 840
Width = 3435
End
Begin VB.TextBox txtUserID
Height = 315
Left = 120
TabIndex = 0
Text = "UserID"
Top = 480
Width = 3435
End
Begin VB.TextBox txtFilter
Enabled = 0 'False
Height = 315
Left = 120
TabIndex = 9
Top = 6120
Width = 8295
End
Begin VB.CommandButton cmdFind
Caption = "&Find"
Enabled = 0 'False
Height = 315
Left = 8460
TabIndex = 10
Top = 6120
Width = 795
End
Begin VB.Frame Frame1
Caption = "Account Information"
Height = 1035
Left = 3660
TabIndex = 11
Top = 120
Width = 5595
Begin VB.Label lblTCPIPPort
Height = 255
Left = 1440
TabIndex = 17
Top = 720
Width = 1815
End
Begin VB.Label lblTCPIPAddress
Height = 255
Left = 1440
TabIndex = 16
Top = 480
Width = 1815
End
Begin VB.Label lblPathToHost
Height = 255
Left = 1440
TabIndex = 15
Top = 240
Width = 1815
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "TCP/IP Port:"
Height = 255
Index = 4
Left = 60
TabIndex = 14
Top = 720
Width = 1275
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "TCP/IP Address:"
Height = 255
Index = 3
Left = 60
TabIndex = 13
Top = 480
Width = 1275
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Path to Host:"
Height = 255
Index = 0
Left = 60
TabIndex = 12
Top = 240
Width = 1275
End
End
Begin VB.Label Label2
Caption = "F&ound"
Enabled = 0 'False
Height = 195
Index = 2
Left = 7680
TabIndex = 7
Top = 2040
Width = 1575
End
Begin ComctlLib.ProgressBar pbProgress
Align = 2 'Align Bottom
Height = 135
Left = 0
TabIndex = 18
Top = 6480
Width = 9390
_ExtentX = 16563
_ExtentY = 238
_Version = 327680
Appearance = 1
MouseIcon = "ABFind.frx":000C
End
Begin ComctlLib.ListView lvABEntries
Height = 3795
Left = 120
TabIndex = 6
Top = 2280
Width = 7515
_ExtentX = 13256
_ExtentY = 6694
View = 3
LabelEdit = 1
LabelWrap = 0 'False
HideSelection = 0 'False
_Version = 327680
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
Enabled = 0 'False
MouseIcon = "ABFind.frx":0028
NumItems = 6
BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "DisplayName"
Object.Tag = ""
Text = "Display Name"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "EmailAddress"
Object.Tag = ""
Text = "E-Mail Address"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "EmailType"
Object.Tag = ""
Text = "E-Mail Type"
Object.Width = 1323
EndProperty
BeginProperty ColumnHeader(4) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "Fields"
Object.Tag = ""
Text = "Fields"
Object.Width = 617
EndProperty
BeginProperty ColumnHeader(5) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "Members"
Object.Tag = ""
Text = "Members"
Object.Width = 1058
EndProperty
BeginProperty ColumnHeader(6) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
Key = "ObjType"
Object.Tag = ""
Text = "Address Type"
Object.Width = 1764
EndProperty
End
Begin VB.Line Line1
X1 = 120
X2 = 9240
Y1 = 1260
Y2 = 1260
End
Begin VB.Label Label2
Caption = "Address &Books"
Enabled = 0 'False
Height = 195
Index = 0
Left = 120
TabIndex = 3
Top = 1380
Width = 9135
End
Begin VB.Label Label2
Caption = "Address Book &Entries"
Enabled = 0 'False
Height = 195
Index = 1
Left = 120
TabIndex = 5
Top = 2040
Width = 7515
End
End
Attribute VB_Name = "frmAddress"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
'/***************************************************************************
'$name: ABFIND.FRM
'$version: 1.0
'$date_modified: 121298
'$description: This app allows you to find address book entries using
' AddressBookEntries.Find("Filter Expression")
'
' Example of a filter expression: (<First Name> MATCHES "Dee")
' Make sure you include the parenthesis.
'$owner: GroupWise SDK Team Lead
'Copyright (c) 1998 Novell, Inc. All Rights Reserved.
'
'THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
'USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE AGREEMENT
'ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS THIS WORK.
'PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO DEVELOPER A
'ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE CODE IN ITS
'PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS TO MARKET,
'DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF DEVELOPER'S
'PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR DEVELOPER'S
'CUSTOMERS WITH RESPECT TO THIS CODE.
'****************************************************************************/
Option Explicit
' Array of enumerations
Private AddressTypeConstants(5) As String
' GroupWise Object API variables
Private GWRootAccount As Object
Private GWABooks As Object
Private GWABEntries As Object
Private GWFoundAddresses As Object
Private Sub cboAddressBooks_Click()
' Get Address Book Entries
Call GetABEntries
End Sub
Private Sub cmdFind_Click()
' Use the Find method to search for address book entries
Call GetFoundAddresses
End Sub
Private Sub cmdLogin_Click()
Dim GWApp As Object
Dim objControl As Object
Dim sMsg As String
Screen.MousePointer = vbHourglass
'Disable controls
Call EnableControls(False)
' Dereference any global objects so you can login again
Set GWFoundAddresses = Nothing
Set GWABEntries = Nothing
Set GWABooks = Nothing
Set GWRootAccount = Nothing
On Error GoTo cmdLogin_Click_Err
Me.Caption = "Creating GroupWare Session...": DoEvents
Set GWApp = CreateObject("NovellGroupWareSession")
If IsObject(GWRootAccount) Then sMsg = ""
Me.Caption = "Logging In...": DoEvents
Set GWRootAccount = GWApp.Login(txtUserID, txtParameters)
If IsObject(GWRootAccount) Then sMsg = ""
' Display Account properties
lblPathToHost = GWRootAccount.PathToHost
lblTCPIPAddress = GWRootAccount.TCPIPAddress
lblTCPIPPort = GWRootAccount.TCPIPPort
'Get Address Books
Call GetAddressBooks
'Enable controls
Call EnableControls(True)
Me.Caption = "Address Book Find": DoEvents
Screen.MousePointer = vbDefault
Exit Sub
cmdLogin_Click_Err:
Screen.MousePointer = vbDefault
sMsg = "In: Sub cmdLogin_Click()" & Chr(10) & _
"Err.Number: " & Err & Chr(10) & _
"Err.Description: " & Err.Description
MsgBox sMsg, vbExclamation
End Sub
Private Sub Form_Load()
'Assign AddressTypeConstants
AddressTypeConstants(0) = "egwUnknown"
AddressTypeConstants(1) = "egwUser"
AddressTypeConstants(2) = "egwCompany"
AddressTypeConstants(3) = "egwResource"
AddressTypeConstants(4) = "egwGroup"
End Sub
Private Sub GetABEntries()
Dim ABEntry As Object
Dim sKey As String
Dim itmX As ListItem
Dim iCount As Integer
Dim iUpdate As Integer
Dim sMsg As String
' Make sure that an address book is selected
If cboAddressBooks.ListIndex = 0 Then Exit Sub
Screen.MousePointer = vbArrowHourglass
' Don't let anyone mess with the controls
Me.Caption = "Getting Address Book Entries"
cmdLogin.Enabled = False
cmdFind.Enabled = False
cboAddressBooks.Enabled = False
lstFound.Enabled = False
' Reset lists and labels
lvABEntries.ListItems.Clear
lstFound.Clear
Label2(1) = "Address Book &Entries"
Label2(2) = "F&ound"
DoEvents
On Error GoTo GetABEntries_Err
' Get the AddressBookEntries collection
Set GWABEntries = GWABooks(cboAddressBooks.ListIndex).AddressBookEntries
' Show progress
Label2(1) = "Address Book &Entries (" & GWABEntries.Count & ")": Label2(1).Refresh
If GWABEntries.Count Then pbProgress.Max = GWABEntries.Count
' iUpdate = 100 'Update listView every 100 entries
On Error Resume Next
' Add Entries to a ListView
For Each ABEntry In GWABEntries
sKey = ABEntry.EmailAddress & ABEntry.DisplayName
Set itmX = lvABEntries.ListItems.Add(, sKey, ABEntry.DisplayName)
With itmX
.SubItems(1) = ABEntry.EmailAddress
.SubItems(2) = ABEntry.EmailType
.SubItems(3) = ABEntry.Fields.Count
.SubItems(4) = ABEntry.Members.Count
.SubItems(5) = AddressTypeConstants(ABEntry.ObjType)
End With
iCount = iCount + 1
pbProgress = iCount
' If iUpdate = iCount Then 'Do some listView tricks
' itmX.EnsureVisible
' lvABEntries.Refresh
' DoEvents
' iUpdate = iCount + 100
' End If
Next
pbProgress = 0
' Ok, you can now mess with the controls
Me.Caption = "Address Book Find": DoEvents
cmdLogin.Enabled = True
cmdFind.Enabled = True
cboAddressBooks.Enabled = True
lstFound.Enabled = True
Screen.MousePointer = vbDefault
Exit Sub
GetABEntries_Err:
Screen.MousePointer = vbDefault
sMsg = "In: Sub GetABEntries()" & Chr(10) & _
"Err.Number: " & Err & Chr(10) & _
"Err.Description: " & Err.Description
MsgBox sMsg, vbExclamation
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Cleanup
Set GWFoundAddresses = Nothing
Set GWABEntries = Nothing
Set GWABooks = Nothing
Set GWRootAccount = Nothing
End
End Sub
Private Sub GetAddressBooks()
Dim objABook As Object
Dim iCount As Integer
Dim sMsg As String
' Control initialization stuf
Me.Caption = "Getting Address Books..."
cboAddressBooks.Clear
lvABEntries.ListItems.Clear
lstFound.Clear
Label2(0) = "Address &Books"
Label2(1) = "Address Book &Entries"
Label2(2) = "F&ound"
DoEvents
On Error GoTo GetAddressBooks_Err
'Get System Address Book
Set GWABooks = GWRootAccount.AddressBooks
' Show progress
Label2(0) = "Address &Books (" & GWABooks.Count & ")": Label2(0).Refresh
If GWABooks.Count Then pbProgress.Max = GWABooks.Count
' Add AddressBooks to combo box
For Each objABook In GWABooks
cboAddressBooks.AddItem objABook.Name
iCount = iCount + 1
pbProgress = iCount
Next
pbProgress = 0
' Show a prompt in the combo box
If cboAddressBooks.ListCount Then
cboAddressBooks.AddItem "<Select an Address Book>", 0
cboAddressBooks.ListIndex = 0
End If
Me.Caption = "Address Book Find": DoEvents
Exit Sub
GetAddressBooks_Err:
Screen.MousePointer = vbDefault
sMsg = "In: Sub GetAddressBooks()" & Chr(10) & _
"Err.Number: " & Err & Chr(10) & _
"Err.Description: " & Err.Description
MsgBox sMsg, vbExclamation
End Sub
Private Sub txtFilter_GotFocus()
cmdFind.Default = True
End Sub
Private Sub txtFilter_LostFocus()
cmdFind.Default = False
End Sub
Private Sub lstFound_Click()
Dim sMsg As String
Dim sKey As String
On Error GoTo lstFound_Click_Err
' When an item in the "Found" list is clicked on show it in the ListView
sKey = GWFoundAddresses(lstFound.ListIndex + 1).EmailAddress & _
GWFoundAddresses(lstFound.ListIndex + 1).DisplayName
Set lvABEntries.SelectedItem = lvABEntries.ListItems(sKey)
lvABEntries.SelectedItem.EnsureVisible
Exit Sub
lstFound_Click_Err:
Screen.MousePointer = vbDefault
sMsg = "In: Sub lstFound_Click()" & Chr(10) & _
"Err.Number: " & Err & Chr(10) & _
"Err.Description: " & Err.Description
MsgBox sMsg, vbExclamation
End Sub
Private Sub txtParameters_GotFocus()
' Position the cursor at the end of any text
txtParameters.SelStart = Len(txtParameters)
cmdLogin.Default = True
End Sub
Private Sub txtUserID_GotFocus()
' Select the text
If txtUserID.SelStart = 0 Then txtUserID.SelLength = Len(txtUserID)
cmdLogin.Default = True
End Sub
Private Sub EnableControls(bSet As Boolean)
' Enables or disables controls
Label2(0).Enabled = bSet
cboAddressBooks.Enabled = bSet
Label2(1).Enabled = bSet
lvABEntries.Enabled = bSet
Label2(2).Enabled = bSet
lstFound.Enabled = bSet
txtFilter.Enabled = bSet
cmdFind.Enabled = bSet
End Sub
Private Sub GetFoundAddresses()
Dim sMsg As String
Dim objAddress As Object
Dim iCount As Integer
Screen.MousePointer = vbHourglass
' Initialization stuff
Me.Caption = "Finding: " & txtFilter
lstFound.Clear
Label2(2) = "F&ound"
DoEvents
On Error GoTo GetFoundAddresses_Err
' Find AddressBookEntries based on the "Find" method
Set GWFoundAddresses = GWABEntries.Find(txtFilter)
' Show progress
Label2(2) = "F&ound (" & GWFoundAddresses.Count & ")": Label2(2).Refresh
If GWFoundAddresses.Count Then pbProgress.Max = GWFoundAddresses.Count
' Add found addresses to ListBox
For Each objAddress In GWFoundAddresses
lstFound.AddItem objAddress.DisplayName
iCount = iCount + 1
pbProgress = iCount
Next
pbProgress = 0
Me.Caption = "Address Book Find": DoEvents
Screen.MousePointer = vbDefault
Exit Sub
GetFoundAddresses_Err:
Screen.MousePointer = vbDefault
sMsg = "In: Sub GetFoundAddresses()" & Chr(10) & _
"Err.Number: " & Err & Chr(10) & _
"Err.Description: " & Err.Description
MsgBox sMsg, vbExclamation
End Sub