Pb with the items.find function with calendar folder

  • Thread starter Thread starter Chadweek
  • Start date Start date
C

Chadweek

Hi,

i'm faced with a problem to find a special item in the calendar folde
using the subject field and a variable.. my code looks like :


Private Sub delAppointment(rdv)
Dim spOutlook As Outlook.Application
Dim spNameSpace As Outlook.NameSpace
Dim spCalendarsFolder As MAPIFolder
Dim spCalendars As Items
Dim spCalendar As TaskItem
Dim spRecips As Recipients
Dim spRecip As Recipient
Dim s As String, sContact As String, s2 As String, filtre As String
Dim i As Long, j As Long

On Error GoTo Handler
Set spOutlook = CreateObject("Outlook.Application")
If spOutlook Is Nothing Then Exit Sub
Set spNameSpace = spOutlook.GetNamespace("MAPI")

Set spCalendarsFolder = spNameSpace.GetDefaultFolder(olFolderCalendar)
Set spCalendars = spCalendarsFolder.Items

filtre = "[Subject] = " & Chr$(34) & rdv & Chr$(34)

Set spCalendar = spCalendars.Find(filtre)
If Not spCalendar Is Nothing Then
MsgBox ("found")
spCalendar.Delete
Else
MsgBox ("not found")
End If

Done:
Set spRecip = Nothing
Set spRecips = Nothing
Set spCalendar = Nothing
Set spCalendars = Nothing
Set spCalendarsFolder = Nothing
Set spNameSpace = Nothing
Set spOutlook = Nothing
Exit Sub
Handler:
MsgBox (Err.Description)
Resume Done
End Sub

i've the error that the type is incompatible when i pass on th
function find

Besides .when i force the filter like that

Set spCalendar = spCalendars.Find("[Subject] =""TEST RDV""")

I've no erro but it don't find my item while is it present in outlook


I'm using outlook 2000 SR1 under win XP and visual basic 6.0

need help....Th
 
Why are you using this declaration:
Dim spCalendar As TaskItem
if you are trying to find an AppointmentItem?
 
Back
Top