Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21369

[RESOLVED] trying to delete all appointments in outlook deletes only 1 item why?

$
0
0
hey,
somehow the code deletes only a single item
and i have a loop in there strange
what i am missing?
this is my code
Code:

    Dim oOutlook As New Outlook.Application
    Dim oNameSpace As Namespace
    Dim Appointment As Object
    Dim OcalItems As Items
    Dim AppointmentDate As String
   
    Set oNameSpace = oOutlook.GetNamespace("MAPI")
    Set OcalItems = oNameSpace.GetDefaultFolder(olFolderCalendar).Items
    AppointmentDate = "06.02.2002 10:30:00"
    Set Appointment = OcalItems.GetFirst
   
    Do While Not (Appointment Is Nothing)
        If Appointment.Start < AppointmentDate Then
            Appointment.Delete
        End If

        Set Appointment = OcalItems.GetNext
    Loop
    Set Appointment = Nothing
    Set OcalItems = Nothing
    Set oNameSpace = Nothing
    Set oOutlook = Nothing

tnx for any help
salsa :)

Viewing all articles
Browse latest Browse all 21369

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>