omegahat / RDCOMClient

GNU General Public License v2.0
77 stars 34 forks source link

Outlook Calendar not returning all meetings #27

Open quickbendelat opened 3 years ago

quickbendelat commented 3 years ago

Hi, I'm not sure if this is a problem with RDCOMClient or if it is something in Outllook. When I connect to my Outlook Calendar to find my meetings, I do not get all the meetings.

library(RDCOMClient)
library(purrr)
library(dplyr)
library(openxlsx)

# COMDate to POSIX
# https://github.com/aecoleman/extrospectr/

.COMDate_to_POSIX <- function(x) {
    stopifnot('COMDate' %in% class(x))
    x %>% purrr::map_dbl( ~ .x) %>% openxlsx::convertToDateTime()
  }

OutApp <- COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
calendar <- outlookNameSpace$GetDefaultFolder(9) #9 is calendar
# https://docs.microsoft.com/en-us/office/vba/api/outlook.oldefaultfolders
Cnt = calendar$Items()$Count()
meetings <- calendar$items
df <- seq(1:Cnt) %>% 
  tibble::enframe(name = NULL, value = "record") %>% 
  dplyr::rowwise() %>% 
  dplyr::mutate(title = meetings(record)[['subject']]) %>% 
  dplyr::filter(title != "") %>% 
  dplyr::mutate(sender = meetings(record)[['Organizer']],
         start = .COMDate_to_POSIX(meetings(record)[['start']]),
         end = .COMDate_to_POSIX(meetings(record)[['end']]))

When I compare df with my calendar, my calendar has more meetings.

Do you think it may be something in the way RDCOClient is obtaining the data from Outlook?

Thanks, Ben