gautamsi / ews-javascript-api

EWS API for TypeScript/JavaScript - ported from OfficeDev/ews-managed-api - node, cordova, meteor, Ionic, Electron, Outlook Add-Ins
MIT License
282 stars 73 forks source link

Get Appointment Organizer and Attendee #392

Open PeterArcurve opened 2 years ago

PeterArcurve commented 2 years ago

FindAppointments can be used to get appointments which contains an Organizer and RequiredAttendees.

Organizer has EmailAddress but the object doesn't contain anything that resembles an email address. Instead it has something like this address = "/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=CE11C450489142DEBA5DBFD9D07C8105-JEROS SHARE/"

RequiredAttendess is always coming back empty even though Outlook indicates there are several required attendees.

How do get the organizer and requiredAttendee email addresses?

gautamsi commented 2 years ago

FindAppointments does not bring down all the properties of item, This is due to nature of search request and controlled by server side of ews.

to get more properties or even load full email address, you want to either use appointmentItem.Load(new propertySet(....)) or Appointment.Bind(....) or ewsService.LoadPropertiesForItems(...)

roy2651 commented 2 years ago

FindAppointments does not bring down all the properties of item, This is due to nature of search request and controlled by server side of ews.

to get more properties or even load full email address, you want to either use appointmentItem.Load(new propertySet(....)) or Appointment.Bind(....) or ewsService.LoadPropertiesForItems(...)

how to use Appointment.Bind(....) such api to get appointment.RequiredAttendees

exch.ImpersonatedUserId = new ews.ImpersonatedUserId(ews.ConnectingIdType.SmtpAddress, xxxx@xxx.com');
var view = new ews.CalendarView(ews.DateTime.Now.Add(-1, "week"), ews.DateTime.Now.Add(1, 'week'));
exch.FindAppointments(ews.WellKnownFolderName.Calendar, view).then(response => {
    let appointments = response.Items;
    for (let appointment of appointments) {
        // console.log(appointment)
        ews.Appointment.Bind(exch, new ews.ItemId(appointment.Id.UniqueId),
                                               new ews.PropertySet(ews.AppointmentSchema.Subject,
                                               ews.AppointmentSchema.Location, 
                                               ews.AppointmentSchema.RequiredAttendees, 
                                               ews.AppointmentSchema.Start,
                                               ews.AppointmentSchema.End, 
                                               ews.AppointmentSchema.Organizer)).then(() => {
                                                                    console.log('Organizer:', appointment.Organizer.name)
                                                                    console.log("Subject: ", appointment.Subject);
                                                                     console.log("Location: ", appointment.Location);
                                                                     let start = appointment.Start.Format('YYYY-MM-DD HH:mm:ss')

                                                                     let end = appointment.End.Format('YYYY-MM-DD HH:mm:ss')

                                                                     console.log("Start: ", start);

                                                                      console.log("End: ", end);
                                                                      appointment.RequiredAttendees.Items.forEach((a) => {
                                                                                 console.log(a.Address);
                                                                       });
                                                  })

    }

}).catch(err => {
    console.log('err:', err)
})   
roy2651 commented 2 years ago

FindAppointments does not bring down all the properties of item, This is due to nature of search request and controlled by server side of ews. to get more properties or even load full email address, you want to either use appointmentItem.Load(new propertySet(....)) or Appointment.Bind(....) or ewsService.LoadPropertiesForItems(...)

how to use Appointment.Bind(....) such api to get appointment.RequiredAttendees

exch.ImpersonatedUserId = new ews.ImpersonatedUserId(ews.ConnectingIdType.SmtpAddress, xxxx@xxx.com');
var view = new ews.CalendarView(ews.DateTime.Now.Add(-1, "week"), ews.DateTime.Now.Add(1, 'week'));
exch.FindAppointments(ews.WellKnownFolderName.Calendar, view).then(response => {
    let appointments = response.Items;
    for (let appointment of appointments) {
        // console.log(appointment)
        ews.Appointment.Bind(exch, new ews.ItemId(appointment.Id.UniqueId),
                                               new ews.PropertySet(ews.AppointmentSchema.Subject,
                                               ews.AppointmentSchema.Location, 
                                               ews.AppointmentSchema.RequiredAttendees, 
                                               ews.AppointmentSchema.Start,
                                               ews.AppointmentSchema.End, 
                                               ews.AppointmentSchema.Organizer)).then(() => {
                                                                    console.log('Organizer:', appointment.Organizer.name)
                                                                    console.log("Subject: ", appointment.Subject);
                                                                     console.log("Location: ", appointment.Location);
                                                                     let start = appointment.Start.Format('YYYY-MM-DD HH:mm:ss')

                                                                     let end = appointment.End.Format('YYYY-MM-DD HH:mm:ss')

                                                                     console.log("Start: ", start);

                                                                      console.log("End: ", end);
                                                                      appointment.RequiredAttendees.Items.forEach((a) => {
                                                                                 console.log(a.Address);
                                                                       });
                                                  })

    }

}).catch(err => {
    console.log('err:', err)
})   

done