Search code examples
node.jsexchangewebservicesews-javascript-api

How to get list of emails who took part in a meeting from EWS using ews-javascript-api?


How can I get all people (emails) that took part in a today meeting with EWS?

So let's say we have this input:

  1. email/password of MS Exchange account
  2. Timeframe: 1 day
  3. Meeting: ID or name of the meeting

How can we get this output? 1. List of emails who joined that meeting

Thank you.


Solution

  • try this. you can only get the attendee information and whether they responded or not. you can not find who joined the meeting, only who intended to join the meeting based on accepted response.

    import { ExchangeService, Uri, WebCredentials, ExchangeVersion, EwsLogging, WellKnownFolderName, CalendarView, DateTime, PropertySet, BasePropertySet, MailboxType, MeetingResponseType } from "ews-javascript-api";
    
    
    let credentials = require("./credentials");
    
    EwsLogging.DebugLogEnabled = false;
    var service = new ExchangeService(ExchangeVersion.Exchange2010);
    service.Credentials = new WebCredentials(credentials.userName, credentials.password);
    service.Url = new Uri("https://outlook.office365.com/Ews/Exchange.asmx");
    
    new CalendarView(DateTime.Now, DateTime.Now.AddDays(3)));    
    
    service.FindAppointments(WellKnownFolderName.Calendar, new CalendarView(DateTime.Now, DateTime.Now.AddDays(3))).then(res => {
    
        if (res.TotalCount > 0) {
            let calItem = res.Items[0];
            calItem.Load(new PropertySet(BasePropertySet.FirstClassProperties)).then(() => {
                // Appointment.Bind(service, new ItemId(itemId), new PropertySet(BasePropertySet.FirstClassProperties)).then(calItem => {
    
                console.log(calItem.Start.toString());
                console.log(calItem.End.toString());
                console.log(calItem.Subject);
                console.log(calItem.Id.UniqueId);
    
                // console.log(calItem.RequiredAttendees);
    
                calItem.RequiredAttendees.GetEnumerator().forEach(x => {
                    console.log(x.Name + "    -     " + x.Address + "     -      " + MailboxType[x.MailboxType] + "      -     " + MeetingResponseType[x.ResponseType] + "     -      " + (x.LastResponseTime ? x.LastResponseTime.toString() : null));
                });
                calItem.OptionalAttendees.GetEnumerator().forEach(x => {
                console.log(x.Name + "    -     " + x.Address + "     -      " + MailboxType[x.MailboxType] + "      -     " + MeetingResponseType[x.ResponseType] + "     -      " + (x.LastResponseTime ? x.LastResponseTime.toString() : null));
            });
            }, err => {
                debugger;
                EwsLogging.DebugLog(err, true);
            });
        }
    }, err => {
        debugger;
        EwsLogging.DebugLog(err, true);
    });