Hi,
ich bin dabei eine eigene Suche in Outlook 2003 zu implementieren. Das ist notwendig weil ich benutzerdefinierte Felder angelegt habe und die Standardsuche diese Felder nicht durchsucht.
Es ist mir geglückt mit Hilfe von Codebeispielen ein Suchformular zu erstellen. Das große Problem ist nur wie suche ich nun in meinen benutzerdefinierten Feldern?
Hier mein Code:
Option Explicit
Dim Mypage
Dim ContactFolder
Dim MyItems
Function Item_Open()
Set Mypage = Item.GetInspector.ModifiedFormPages(„Nachricht“)
Set ContactFolder = Application.GetNameSpace(„MAPI“).GetDefaultFolder(10)
'Set the Default library to be your local contact list
MyPage.LblContact.Caption = " " & Contactfolder.Name
End Function
Sub SearchButton_Click
Dim Input
Dim LastLetter
Dim UpperLimit
Dim SearchItem
Mypage.Clist.Clear
Mypage.Textbox1 = „“
Set MyItems = ContactFolder.Items
Set Input = Mypage.CName
If Input „“ Then
LastLetter = ChrW(AscW(Right(Input,1))+1)
UpperLimit = Left(Input,Len(Input)-1) & LastLetter
Mypage.Low.Value = Input
Mypage.Up.Value = UpperLimit
'In der folgenden Zeile möchte ich die Suche nach den Benutzerfeldern
'definieren, was jedoch nicht so funktioniert wie ich mir das vorstelle
Set SearchItem = MyItems.Find _
("([FirstName]>="""&Input&""„and[FirstName]=“""&Input&""„and[MiddleName]=“""&Input&"""and[LastName] „Nothing“
Mypage.Clist.AddItem(SearchItem.FullName)
Set SearchItem = MyItems.FindNext
Wend
End If
call CheckListItems
End Sub
Sub DispItem_click()
Dim SelectedItem
Dim DisplayItem
Dim i
For i = 0 To Mypage.Clist.ListCount
If Mypage.Clist.Selected(i) = True Then
SelectedItem = Mypage.Clist.List(i,0)
Set MyItems = ContactFolder.Items
Set DisplayItem = MyItems.Find("[FullName] = „“"&SelectedItem&"""")
DisplayItem.Display
End If
Next
End Sub
Sub CboChoose_click()
Dim ErrCheck
'Need an error check to get around user pressing cancel
On Error Resume Next
'Use the pickfolder method to bring up the folder chooser
Set ErrCheck = Application.Getnamespace(„MAPI“).Pickfolder
If Err = 0 then
'User Pressed Cancel
'Check to see if the user returned nothing
If ErrCheck = Null then
'If so then leave Contact Folder as it was
Else
'Since we’ve chosen a new contact list, get rid of the old data
Call ClearInfo()
'Otherwise Update it
Set ContactFolder = ErrCheck
MyPage.LblContact.Caption = " " & Contactfolder.Name
End if
else
MsgBox "Outlook Form Error!!! " & chr(13) & „Unable to Continue with operation.“,0,„Search Contacts Form…“
End if
End Sub
Sub CheckListItems()
If MyPage.Clist.listcount = 0 Then
'There are no rows to choose from
MyPage.DispItem.Enabled = False
'Inform User that no data found
MsgBox „No Contacts Found to Match Query.“ & chr(13) & „Please Expand Your Search Criteria.“,0,„Search Contacts Form…“
Else
MyPage.DispItem.Enabled = True
'Select the first contact in the List
MyPage.Clist.Listindex = 0
End If
End Sub
Thx
lx