Импорт общего календаря Outlook в Excel - PullRequest
0 голосов
/ 13 мая 2019

Я хочу импортировать встречи в календаре Outlook с общей группой в Excel.

Как вы увидите из приведенного ниже кода, я использовал объект GetSharedDefaultFolder, но получил следующую ошибку:

Невозможно открыть почтовый ящик, поскольку эта запись адресной книги не соответствует пользователю электронной почты.

Пожалуйста, помогите мне.

Большое спасибо.

Sub ResolveName()
    ' déclaration des variables
    Dim outlookApp As Outlook.Application
    Dim myNamespace As Outlook.Namespace
    Dim myRecipient As Outlook.Recipient
    Dim CalendarFolder As Outlook.folder
    Dim calendarApp As Outlook.AppointmentItem
    Dim calendarItem As Outlook.Items
    Dim i As Long

    Set outlookApp = New Outlook.Application
    Set myNamespace = outlookApp.GetNamespace("MAPI")
    Set myRecipient = myNamespace.CreateRecipient("dp-TECCR-FormationdesrepartiteursCCRediteurs@hydro.qc.ca")
    i = 2

    myRecipient.Resolve
    Range("A1:D1").Value = Array("Subject", "from", "date", "location")
    If myRecipient.Resolved Then
        Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
        For Each calendarApp In CalendarFolder.Items
            Cells(i, 1).Value = calendarItem.Subject
            Cells(i, 2).Value = calendarItem.Start
            Cells(i, 3).Value = calendarItem.End
            Cells(i, 4).Value = calendarItem.Location
            Cells(i, 5).Value = calendarItem.MeetingStatus
            i = i + 1
        Next
    End If

    Set outlookApp = Nothing
    Set myNamespace = Nothing
    Set myRecipient = Nothing
    Set CalendarFolder = Nothing
    Set calendarItem = Nothing
End Sub
...