1

I am trying to access the shared calendar of a exchange server user and i have found a code that was shared in the stackoverflow. This code works as follows. It first browses through user folders and gets the shared calendars of the logged in user. To get to the calendar data the code is requesting some extended properties from the server. The requested extended properties are as follows:

  • PidTagWlinkAddressBookEID
  • PidTagWlinkGroupName

Later in the code it is referring "PidTagWlinkAddressBookEID" to retrieve folder of the shared calendar.

The problem I have is when it is reading the data send by the server. The results does not contain "PidTagWlinkAddressBookEID". I have tried to find a solution to this matter but couldn't find any. To get this information is should I configure server?

The referred code is this:

static Dictionary<string, Folder> GetSharedCalendarFolders(ExchangeService service, String mbMailboxname)
{
    Dictionary<String, Folder> rtList = new System.Collections.Generic.Dictionary<string, Folder>();

    FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Root, mbMailboxname);
    FolderView fvFolderView = new FolderView(1000);
    SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "Common Views");
    FindFoldersResults ffoldres = service.FindFolders(rfRootFolderid, sfSearchFilter, fvFolderView);
    if (ffoldres.Folders.Count == 1)
    {

        PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
        ExtendedPropertyDefinition PidTagWlinkAddressBookEID = new ExtendedPropertyDefinition(0x6854, MapiPropertyType.Binary);
        ExtendedPropertyDefinition PidTagWlinkFolderType = new ExtendedPropertyDefinition(0x684F, MapiPropertyType.Binary);
        ExtendedPropertyDefinition PidTagWlinkGroupName = new ExtendedPropertyDefinition(0x6851, MapiPropertyType.String);

        psPropset.Add(PidTagWlinkAddressBookEID);
        psPropset.Add(PidTagWlinkFolderType);
        ItemView iv = new ItemView(1000);
        iv.PropertySet = psPropset;
        iv.Traversal = ItemTraversal.Associated;

        SearchFilter cntSearch = new SearchFilter.IsEqualTo(PidTagWlinkGroupName, "Other Calendars");
        FindItemsResults<Item> fiResults = ffoldres.Folders[0].FindItems(cntSearch, iv);
        foreach (Item itItem in fiResults.Items)
        {
            try
            {
                object GroupName = null;
                object WlinkAddressBookEID = null;
                if (itItem.TryGetProperty(PidTagWlinkAddressBookEID, out WlinkAddressBookEID))
                {

                    byte[] ssStoreID = (byte[])WlinkAddressBookEID;
                    int leLegDnStart = 0;
                    String lnLegDN = "";
                    for (int ssArraynum = (ssStoreID.Length - 2); ssArraynum != 0; ssArraynum--)
                    {
                        if (ssStoreID[ssArraynum] == 0)
                        {
                            leLegDnStart = ssArraynum;
                            lnLegDN = System.Text.ASCIIEncoding.ASCII.GetString(ssStoreID, leLegDnStart + 1, (ssStoreID.Length - (leLegDnStart + 2)));
                            ssArraynum = 1;
                        }
                    }
                    NameResolutionCollection ncCol = service.ResolveName(lnLegDN, ResolveNameSearchLocation.DirectoryOnly, true);
                    if (ncCol.Count > 0)
                    {

                        FolderId SharedCalendarId = new FolderId(WellKnownFolderName.Calendar, ncCol[0].Mailbox.Address);
                        Folder SharedCalendaFolder = Folder.Bind(service, SharedCalendarId);
                        rtList.Add(ncCol[0].Mailbox.Address, SharedCalendaFolder);


                    }

                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

        }
    }
    return rtList;
}

quoted from this answer: https://stackoverflow.com/a/23773834/6088233

Community
  • 1
  • 1
  • If you post the value of the Id your getting I can probably tell you what type of Id is and how to decode it. Its a workaround type solution – Glen Scales Jun 09 '16 at 04:53
  • HI @glen-scales , I think the server doesn't send the ID with the data. I have checked the loaded by using itItem.GetLoadedPropertyDefinitions(); but only "PidTagWlinkGroupName" returns. I've took a screenshot of the the result of GetLoadedPropertyDefinitions. [Image link](http://imgur.com/EtdkPNG) thanks in advance – Janaka Poddalgoda Jun 09 '16 at 06:00
  • You will need to use a Mapi editor like OutlookSpy or MFCMapi to look at one of the Items your trying to access and this will tell you all the properties that are available. My guess is that its not the same type of Shared Calendar folder the code I posted works with so you may need to engineer your own solution around the properties you have. – Glen Scales Jun 09 '16 at 09:28
  • Thank you @GlenScales for the reply. I will try to find a solution using the mentioned apps as you have said. :) – Janaka Poddalgoda Jun 13 '16 at 03:26

0 Answers0