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
281 stars 72 forks source link

Create an appointment by using EWS #390

Closed githubjosh closed 1 year ago

githubjosh commented 2 years ago

Any interest in adding the endpoint to Create an appointment by using EWS? Seems like a high value, low effort addition to this library.

SOAP Request Example - Create an appointment by using EWS

gautamsi commented 2 years ago

This should already be working.

Have you tried and found it missing?

kstankov commented 2 years ago

Hi, not sure if I got your request correctly, but if you mean the option to create an appointment, it is there. You do that by creating new Appointment, passing the service, then setting subject, start, end, etc. and then calling Save().

Hth.

On 19 Oct 2021, 00:04, at 00:04, Josh Arndt @.***> wrote:

Any interest in adding the endpoint to Create an appointment by using EWS? Seems like a high value, low effort addition to this library.

SOAP Request

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/gautamsi/ews-javascript-api/issues/390

bfredo123 commented 1 year ago

I have tried the following (from the Microsoft example):

  var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2010_SP1);
  exch.Credentials = new ews.WebCredentials(user.email, user.password);
  exch.Url = new ews.Uri(user.url);

  let meeting = new ews.Appointment(exch)
  meeting.Subject="my meeting"
  meeting.Body="body"
  meeting.Start = ews.DateTime.Now.AddHours(1)
  meeting.End = meeting.Start.AddHours(1) 
  meeting.Location="location"
  meeting.Save(ews.SendInvitationsMode.SendToNone).then(x => {
    console.log("save ok", x)
  }).catch(err => {
    console.error("save KO", err)
  })

and I get this error:

save KO TypeError: complexProperty.WriteToXml is not a function
    at ComplexPropertyDefinition.WritePropertyValueToXml (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/PropertyDefinitions/ComplexPropertyDefinitionBase.js:89:29)
    at PropertyBag.WriteToXml (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/PropertyBag.js:560:40)
    at Appointment.WriteToXml (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/ServiceObjects/ServiceObject.js:293:43)
    at CreateItemRequest.WriteElementsToXml (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/CreateRequest.js:44:17)
    at CreateItemRequest.WriteBodyToXml (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/ServiceRequestBase.js:453:14)
    at CreateItemRequest.WriteToXml (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/ServiceRequestBase.js:525:14)
    at CreateItemRequest.EmitRequest (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/ServiceRequestBase.js:158:18)
    at CreateItemRequest.BuildXHR (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/ServiceRequestBase.js:124:14)
    at InternalExecute.Promise (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/SimpleServiceRequestBase.js:35:32)
    at new Promise (<anonymous>)
    at CreateItemRequest.InternalExecute (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/SimpleServiceRequestBase.js:34:16)
    at Execute.Promise (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/MultiResponseServiceRequest.js:28:18)
    at new Promise (<anonymous>)
    at CreateItemRequest.Execute (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/Requests/MultiResponseServiceRequest.js:27:16)
    at ExchangeService.InternalCreateItems (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/ExchangeService.js:755:24)
    at ExchangeService.CreateItem (/Users/frederic/tmp/microsoft-ews/node_modules/ews-javascript-api/js/Core/ExchangeService.js:552:21)

Any suggestion to make it work? Many thanks!

bfredo123 commented 1 year ago

My bad, I have found in https://github.com/gautamsi/ews-javascript-api/issues/122 that I should use new ews.MessageBody("body") to set the body.