Hello,
I hope this is the right forum to ask this question.
My requirement is as mentioned below:
-> I need to create an appointment on my Default calendar and the same on other calendars that are shared with me by using Exchange Services (EWS).
-> By shared, i mean those calendars that I can see under my 'Other Calendars' group in Office 365.
-> Now, I have reffered many links which help to create appointments on my mailbox, default Calendar. This part works fine(Link : (http://technico.qnownow.com/how-to-create-appointment-using-ews-exchange-web-services/)
-> Then I moved on to access shared calendars so that I can create the same appointment on them.
-> However I am not able to get the proper folderID of these calendars.Inline Code Example Here
public List<Folder> GetSharedCalendarFolders(String mbMailboxname)
{
List<Folder> rtList = new List<Folder>();
FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Root, mbMailboxname);
FolderView fvFolderView = new FolderView(1000);
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "Common Views");
FindFoldersResults ffoldres = exchangeService.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 = exchangeService.ResolveName(lnLegDN, ResolveNameSearchLocation.DirectoryOnly, true);
if (ncCol.Count > 0)
{
FolderId SharedCalendarId = new FolderId(WellKnownFolderName.Calendar, ncCol[0].Mailbox.Address);
Folder SharedCalendaFolder = Folder.Bind(exchangeService, SharedCalendarId);
rtList.Add(SharedCalendaFolder);
}
}
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
}
}
return rtList;
}
(Above code is taken from http://stackoverflow.com/questions/23766747/ews-access-all-shared-calendars)
The code works fine till I get the fiResults collection.
It's a collection of* items (Microsoft.Exchange.WebServices.Data.Item class)*
The problem is when i iterate over this collection (as you can see in the code) , i am trying to get the PidTagWlinkAddressBookEID property value in each item and its not present in the item.
And this is the reason I am not able to retrieve the FolderID at the end.
But i tried number of ways to do it since i get the collection of items and I can see my shared calendars' names in those items.
Since i created the shared calendars, I tried to use my mailbox address at the end in this part of the code :
FolderId SharedCalendarId = new FolderId(WellKnownFolderName.Calendar, ncCol[0].Mailbox.Address);
However the calendar retrieved in this case is the default calendar with displayName as Calendar.
Since each item in the itemcollection ( fiResults collection) represents the corresponding shared calendar
Please let me know if we can use any property in the Item class to create an appointment as :
appointment.Save(Something from the Item class, SendInvitationsMode.SendToNone);
Also, please let me know if there is any other way to create appointments on Shared Calendars in my mailbox.
Thanks