Read Proposed Start Time suggested by the invited people

I am developing VBA code to import from Outlook the Proposed Start Time suggested by the invited people.

I have an error

Object doesn't support this property or method

in strNewTimeProposed = objMeeting.GetAssociatedAppointment(True).ProposedStartTime

Function SheetExists(sheetName As String, Optional wb As Workbook) As Boolean
    Dim s As Worksheet
    On Error Resume Next
    If wb Is Nothing Then Set wb = ThisWorkbook
    Set s = wb.Sheets(sheetName)
    SheetExists = Not s Is Nothing
End Function

Sub SaveNewTimeProposedToExcel()
    Dim objNamespace As Outlook.Namespace
    Dim objFolder As Outlook.Folder
    Dim objMail As Outlook.MailItem
    Dim strNewTimeProposed As Date
    Dim objWorkbook As Excel.Workbook
    Dim objMeeting As Outlook.MeetingItem
    Dim objItem As Object
    Dim lngRow As Long
    Set Base = ActiveWorkbook
    'Define o namespace e a pasta da caixa de entrada
    Set objNamespace = Outlook.Application.GetNamespace("MAPI")
    Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
    'Abre o arquivo existente
    Set objWorkbook = Workbooks.Open("C:\Users\genascim\Desktop\Gregory Project\Gregory_database.xlsx")
    'Verifica se a planilha "New Time Proposed" já existe e cria uma nova planilha com um nome diferente, se necessário
    Dim strSheetName As String
    Dim intSheetCount As Integer
    intSheetCount = 1
    strSheetName = "New Time Proposed"
    Do While SheetExists(strSheetName, objWorkbook)
        intSheetCount = intSheetCount + 1
        strSheetName = "New Time Proposed " & intSheetCount
    'Adiciona a nova planilha e define a primeira linha como cabeçalho
    Set objWorksheet = objWorkbook.Sheets.Add(After:=objWorkbook.Sheets(objWorkbook.Sheets.Count))
    objWorksheet.Name = strSheetName
    objWorksheet.Cells(1, 1).Value = "Remetente"
    objWorksheet.Cells(1, 2).Value = "Nova hora proposta"
    Set objMailItems = objFolder.Items.Restrict("[ReceivedTime] > '" & Format(Date - 7, "ddddd h:nn AMPM") & "'")
    'Loop através dos itens da pasta da caixa de entrada
    For Each objItem In objMailItems
        If TypeOf objItem Is Outlook.MailItem Then
            Set objMail = objItem
            Debug.Print "Processing email: " & objMail.Subject
        ElseIf TypeOf objItem Is Outlook.MeetingItem Then
            Set objMeeting = objItem

            'Check if the email item is a meeting request
            If objMeeting.MessageClass = "IPM.Schedule.Meeting.Resp.Pos" Or objMeeting.MessageClass = "IPM.Schedule.Meeting.Resp.Neg" Or objMeeting.MessageClass = "IPM.Schedule.Meeting.Resp.Tent" Then
                    'Check if the response contains a new time proposal
                    If InStr(1, objMeeting.Subject, "New Time Proposed", vbTextCompare) > 0 Then
                        'Extract the new time proposed
                        If Not objMeeting.GetAssociatedAppointment(True) Is Nothing Then
                            **strNewTimeProposed = objMeeting.GetAssociatedAppointment(True).ProposedStartTime**
                        End If

                    'Add the sender and new time proposed to the worksheet
                    lngRow = objWorksheet.Cells(objWorksheet.Rows.Count, 1).End(xlUp).Row + 1
                    objWorksheet.Cells(lngRow, 1).Value = objMeeting.SenderName
                    objWorksheet.Cells(lngRow, 2).Value = strNewTimeProposed
                End If

            End If
        End If
    Next objItem
    'Salva o livro
End Sub

The variable strNewTimeProposed needs to receive the time proposed by the guests.


  • AppointmentItem object does not expose the ProposedStartTime property - see https://learn.microsoft.com/en-us/office/vba/api/outlook.appointmentitem

    Keep in mind that proposed new times cannot be stored on the parent appointment itself - imagine multiple attendees proposing different times. Which one do you store? These times are stored on the per-recipient basis (see below)

    The MeetingItem object (that carries a reply from an attendee proposing new time) is a different matter - the times can be accessed using MeetingItem.PropertyAccessor.GetProperty. The DASL property names are "http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82500040" (called AppointmentProposedStartWhole) and "http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/82510040" (called AppointmentProposedEndWhole)

    On the parent appointment, proposed new times are stored on the per-attendee basis and can be accessed using Recipient.PropertyAccessor.GetProperty (where Recipient object comes from the AppointmentItem.Recipients collection). The DASL property names are "http://schemas.microsoft.com/mapi/proptag/0x5FE30040" (PR_RECIPIENT_PROPOSEDSTARTTIME), "http://schemas.microsoft.com/mapi/proptag/0x5FE40040" (PR_RECIPIENT_PROPOSEDENDTIME), "http://schemas.microsoft.com/mapi/proptag/0x5FFB0040" (PR_RECIPIENT_TRACKSTATUS_TIME).

    You can see these (and all other) properties live in OutlookSpy (I am its author) - select the meeting reply or the appointment and click IMessage button.