Setting MeetingStatus to CdoNonMeeting using CDO will cause the AllDay flag to not be set on an occurance in Outlook.

If you use CDO 1.21 to set the MeetingStatus to CdoNonMeeting for a single occurance of an all day recurring appointment, you will find that the AllDay flag is not set when the appointment is converted to a meeting and accepted by the attendee.

Private Sub cmdMakeInstanceAllDay_Click()
    Dim objSession As mapi.Session
    Dim ObjMessage As mapi.Message
    Dim objRecipient As mapi.Recipient
    Dim oAppointment As mapi.AppointmentItem
    Dim oCalendarFolder As mapi.Folder
    Dim objOrig As AppointmentItem
    Dim objRecPatt As RecurrencePattern
    Dim objRecip As Recipient
    ' This is what I'm searching for
    Dim sFromDate As String
    Dim sToDate As String
    Dim sFindSubject As String
    ' This is the recurrence to pick  - i had setup a 4 day, daily appt starting 1/7/08 in Outlook.
    sToDate = "1/8/2008 8:00 AM"
    sFromDate = "1/8/2008 6:00 PM"
    sFindSubject = "testdaily"
    'Create the Session Object.
    Set objSession = New mapi.Session
    Dim oMsgCollection As Object
    Dim oMsgFilter As Object
    'Logon using the session object.
    'objSession.Logon "", "", False, True, 0, True, "myserver" & vbLf & "mymailbox"

    Set oCalendarFolder = objSession.GetDefaultFolder(CdoDefaultFolderCalendar)
    ' We are going to filter to get appts....
    Set oMsgCollection = oCalendarFolder.Messages
    Set oMsgFilter = oMsgCollection.Filter
    oMsgFilter.Fields.Add CdoPR_START_DATE, sFromDate
    oMsgFilter.Fields.Add CdoPR_END_DATE, sToDate
    Set oAppointment = oMsgCollection.GetFirst
    Do While Not oAppointment Is Nothing
         If oAppointment.Subject = sFindSubject Then
            oAppointment.StartTime = #1/8/2008#
            oAppointment.EndTime = #1/8/2008#
            oAppointment.AllDayEvent = True
            oAppointment.Subject = "testdailyallday"

            oAppointment.MeetingStatus = CdoNonMeeting
            oAppointment.Update True, True
         End If
         Set oAppointment = oMsgCollection.GetNext      ' Now, let’s look at the next item.
         'Note: oAppointment should be set to Nothing since this filter should have returned 1 appt.
    Set oAppointment = Nothing
    Set oMsgCollection = Nothing
    Set oMsgFilter = Nothing
    Set oCalendarFolder = Nothing
    Set objSession = Nothing
End Sub

Normally you would never set MeetingStatus to CdoNonMeeting for an appointment. However, you can work around this problem by using something like the following lines.

    If oAppointment.MeetingStatus <> CdoNonMeeting Then
        oAppointment.MeetingStatus = CdoNonMeeting
    End If

Comments (0)

Skip to main content