Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contact.Save not working properly || email adresses, phonenumbers etc. not saved #137

Closed
davidLeimroth opened this issue Dec 6, 2016 · 6 comments
Assignees
Milestone

Comments

@davidLeimroth
Copy link

davidLeimroth commented Dec 6, 2016

I'm trying to create a new Contact, but as far as I can tell, only names (GivenName, MiddleName, Surname) and CompanyName are sent to server.

Did I skip any step?

This might be somehow related to:

Underneath is a simplified version of my code

import * as ews from 'ews-javascript-api';

/* ... */
let exch = new ews.ExchangeService(exchVersion)
exch.Url = //...

let folderId = /* folder id of folder somewhere in public folders */

let c = {
      GivenName: 'Max',
      Surname: 'Mustermann',
      EmailAddress: 'max@mustermmann.muster',
      HomePhone: '000/1111111',
      Street: 'SampleStreet',
      City: 'SampleCity',
      PostalCode: '12345',
      CompanyName: 'SampleCompany'
    };

/* ... */

      let contact = new ews.Contact(exch);

      contact.PhoneNumbers[ews.PhoneNumberKey.HomePhone] = c.HomePhone;

      // Specify two email addresses.
      contact.EmailAddresses[ews.EmailAddressKey.EmailAddress1] = new ews.EmailAddress(c.EmailAddress);
      
      /* Does not work */
      // Email adresses as specified in https://github.com/gautamsi/ews-javascript-api/issues/123
      // let email = "new@email.com";
      // let emailEntry1 = new ews.EmailAddressEntry('EmailAddress1', new ews.EmailAddress('home', email));
      // contact.EmailAddresses._setItem(ews.EmailAddressKey.EmailAddress1, emailEntry1);

      contact.GivenName = c.GivenName;
      contact.MiddleName = c.MiddleName;
      contact.Surname = c.Surname;
      contact.CompanyName = c.CompanyName;

      /* Does't work */
      // Specify two IM addresses.
      contact.ImAddresses[ews.ImAddressKey.ImAddress1] = "brianIM1@contoso.com";
      contact.ImAddresses[ews.ImAddressKey.ImAddress2] = " brianIM2@contoso.com";

      // Specify the home address.
      let privateAdress = new ews.PhysicalAddressEntry();
      privateAdress.Street = c.Street;
      privateAdress.City = c.City;
      privateAdress.PostalCode = c.PostalCode;
      contact.PhysicalAddresses[ews.PhysicalAddressKey.Home] = privateAdress;

/* ... */

      contact.Save(folderId)

Console output

/* ... */
[ComplexProperty.Changed] OnChange events not fired due to circular calling, todo: fix needed
/* ... */

Edit 1:
Emailaddresses etc. are not added to contact.PropertyBag.addedProperties

The sent xml is the following:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2016">
    </t:RequestServerVersion>
  </soap:Header>
  <soap:Body>
    <m:CreateItem MessageDisposition="SaveOnly">
      <m:SavedItemFolderId>
        <t:FolderId Id="MyFolderId" ChangeKey="MyChangeId">
        </t:FolderId>
      </m:SavedItemFolderId>
      <m:Items>
        <t:Contact>
          <t:GivenName>Max</t:GivenName>
          <t:CompanyName>SampleCompany</t:CompanyName>
          <t:Surname>Mustermann</t:Surname>
        </t:Contact>
      </m:Items>
    </m:CreateItem>
  </soap:Body>
</soap:Envelope>

It looks like there are a few things missing.

@gautamsi
Copy link
Owner

can you try installing dev version and provide feedback. npm i ews-javascript-api@next.

there is a caveat in removing/replacing these entries, see the blog for more details

@davidLeimroth
Copy link
Author

Going to try it next weekend

@gautamsi
Copy link
Owner

@davidLeimroth were you able to test this?

@gautamsi
Copy link
Owner

should be fixed, please reopen if still facing issue.

@chigivigi
Copy link

I am having the same issue. My newly created test contact only holds values for display name and Id. Everything else is either empty or throws exception 'Microsoft.Exchange.WebServices.Data.ServiceObjectPropertyException'.

@gautamsi
Copy link
Owner

gautamsi commented Dec 7, 2017

@chigivigi it seems like different issue, please open another issue for tracking release bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants