outlook "find [subject]" with calendar items returns nothing

D

d. motsiff

hey all --

Im playing with some code samples found at slipstick.com and/or
outlookcode.com -- I forget -- but the find method with [subject] is
not working at all for me. If I walk through all my Calendar items
i can see this appointment in there, no problems, but when i try to
use find to get at it, no dice. won't come back.

I'm obviously missing something *VERY* easy and simple.... ...but
hrrrmpf! I know Im going to kick myself, but I've been squinting at
it for hours now. Can anyone take a peek and see why the following
code doesnt work?

Thanks,
D


--------------------------------------------

'call [subject] find function with a VALID, LEGIT, PRE-TESTED appt
subject!
DebugPrintCalendarItem("DR. HEARST - BLOOD WORK ON J NASH")

---------------------------------------------

Public Sub DebugPrintCalendarItem(ByVal inSubject As String)

'Print Calendar items with the [subject] string "inSubject" passed
in
Dim olApp As Outlook.Application
Dim nspNameSpace As Outlook.Namespace
Dim oCalItems As Items
Dim oCalFoundItems As Object
Dim oItem As Object
Dim fndStr As String

' Get references to the Outlook Contacts folder.
Set olApp = New Outlook.Application
Set nspNameSpace = olApp.GetNamespace("MAPI")
Set oCalItems = nspNameSpace.GetDefaultFolder(olFolderCalendar).Items
' build the search string
fndStr = "[subject]= " & Quote(inSubject)
Debug.Print (fndStr) ' [subject]= "DR. HEARST - BLOOD WORK ON J
NASH"
Set oCalFoundItems = oCalItems.Find(fndStr)

On Error Resume Next
For Each oItem In oCalFoundItems
Debug.Print (oItem.Subject & "~" & oItem.Body & "~" & _
oItem.Start & "~" & oItem.EntryID)
Next

End Sub
 
K

Ken Slovak - [MVP - Outlook]

Items.Find returns an object, not a collection. If you want a filtered
collection use Items.Restrict.
 
D

d. motsiff

Ken Slovak - said:
Items.Find returns an object, not a collection. If you want a filtered
collection use Items.Restrict.


BINGO! I'm expecting collection and getting one object.

Thanks Ken.
Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top