Search code examples
outlookmicrosoft-graph-apioutlook-web-addins

Outlook Addin Documentation: Format of Location and EmailUser


I'm trying to sync values of location and attendees between Outlook Web event creation screen and my outlook Addin. In documentation, as shown in screenshot attached below, type of location is given as String|Location.

Doc Screenshot

I clicked on the link of Location and didn't find a description of type Location anywhere. In the documentation, Location is used as string, but the problem arise when I try to set a location from my addin to Location field of Outlook event screen. When I checked the value, I got it as shown below

console I'm setting the value of location as

Office.context.mailbox.item.location.setAsync(emailAddress_to_add);

Same is the case for EmailUser in case of Recipients/Attendees.

Can anyone tell me the correct format, i.e. Location and EmailUser in which I should set the location and attendees?


Solution

  • If your location is just a string (not associated with an email address), you can use location APIs

    Office.context.mailbox.item.location
    

    In read mode, location is just a string property on Office.context.mailbox.item.

    In compose mode, location returns an object of type Location, on this object you can perform get/set operation.

    If you want to set a location which has an associated email address, then you can make use of EnhancedLocation preview API.

    Office.context.mailbox.item.enhancedLocation
    

    In read and compose mode, enhancedlocation will return an object of type EnhancedLocation, on which you can perform add/get/remove operation.

    var locations = [
        {
            "id": "ConfRoom101@contoso.com",
            "type": Office.MailboxEnums.LocationType.Room
        }
    ];
    Office.context.mailbox.item.enhancedLocation.addAsync(locations);