Search code examples
powershellexchange-serverexchangewebservicesoffice365api

Getting to UM voicemail greetings for users in o365 using PowerShell or EWS


Hopefully a simple question - at one time I know when user's recorded their personal greetings for UM voicemail in o365 (regular greeting and/or extended absence greeting) these were stored in their Exchange inbox using a special item type (i.e. "IPM.Configuration.Um.CustomGreetings.External"). However setting up my test o365 setup, getting UM configured and all that, after recording my personal greeting and going through each item starting from the root of my inbox, (some 900+ items - lots of odd stuff in there) - I don't see anything like this any more. Lots of log, activity items, some messages but nothing about greetings. Extracting everything that could cast to an email type to a folder I went through each one - nothing promising. anyone have any clues where the custom greetings for users UM (not auto attendant recordings - that's a different beast) has gone off to and how to get to it?
thanks much.


Solution

  • Got this working after a bit of flailing.

    Ben Lye's post that Glen Scales provided in the comments above was what got me from A to B - Thanks Glen. http://www.onesimplescript.com/2015/07/getting-um-voicemail-greetings-in.html

    In related news Glen's very excellent PowerShell plug in for FAI exploration was also very helpful and can save you a bunch of time ramping up on the Folder Associated Information: https://gsexdev.blogspot.com/2018/03/ews-fai-module-for-browsing-and.html

    For those stumbling around with this in .NET using EWS, here's a quick stripped down blurb of code for fetching the standard and extended greeting recordings for a user - took me longer to slog through this than it should have, perhaps this can save someone a bit of time down the road:

    note to run this against multiple mailboxes you'll need to have configured impersonation for your account you're authenticating with for EWS functions.

            ExchangeService _service;
            _service = new ExchangeService(ExchangeVersion.Exchange2016); // Exchange2013_SP1);
            _service.Credentials = new WebCredentials("user@domain", "myPw");
            _service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
    
            //select the user you're fetching greetings for
            _service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "user@domain");
    
            //get the root folder for the current account
            var oParamList = new List<FolderId> {WellKnownFolderName.Root};
            var oTemp = _service.BindToFolders(oParamList, PropertySet.FirstClassProperties);
            var oRoot = oTemp.First().Folder;
    
            var oView = new ItemView(50)
            {
                PropertySet = new PropertySet(BasePropertySet.FirstClassProperties),
                Traversal = ItemTraversal.Associated
            };
            SearchFilter oGreetingFilter = new SearchFilter.ContainsSubstring(ItemSchema.ItemClass,
                "IPM.Configuration.Um.CustomGreetings", ContainmentMode.Substring, ComparisonMode.IgnoreCase);
            var oResults = _service.FindItems(oRoot.Id, oGreetingFilter, oView);
    
            //fetch the binary for the greetings as values 
            var oPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
            var oRoamingBinary = new ExtendedPropertyDefinition(31753, MapiPropertyType.Binary);
            oPropSet.Add(oRoamingBinary);
            _service.LoadPropertiesForItems(oResults, oPropSet);
    
            var strFileName = "";
            foreach (var oItem in oResults.Items)
            {
                if (oItem.ItemClass.Equals("IPM.Configuration.Um.CustomGreetings.External",
                    StringComparison.InvariantCultureIgnoreCase))
                    strFileName = "jlindborg_Standard.wav";
                if (oItem.ItemClass.Equals("IPM.Configuration.Um.CustomGreetings.Oof",
                    StringComparison.InvariantCultureIgnoreCase))
                    strFileName = "jlindborg_Extended.wav";
                File.WriteAllBytes("d:\\" + strFileName, (byte[]) oItem.ExtendedProperties.First().Value);
            }
        }