C# - Outlook - get access to a new calendar -
C# - Outlook - get access to a new calendar -
i trying read calendars have in outlook c#, have problem getting access ones create within outlook (right click -> new calendar).
i'm trying them by:
outlook.application app = new outlook.application(); outlook.namespace ns = app.getnamespace("mapi"); outlook.mapifolder folderss = ns.getdefaultfolder(outlook.oldefaultfolders.olfoldercalendar);
or by:
application.session.stores
but none of them holds new calendar.
do have thought how reach them?
calendars folders
defaultitemtype
olitemtype.olappointmentitem
. can created in of outlook stores
on level of folder
hierarchy.
assuming calendar created in root folder of 1 of stores
, next c#
code find it:
void findmycalendar(string name) { string path = null; outlook.application app = new outlook.application(); outlook.namespace ns = app.getnamespace("mapi"); // there may more 1 store // each .ost , .pst file store outlook.folders folders = ns.folders; foreach (outlook.folder folder in folders) { outlook.mapifolder root = folder; path = findcalendar(root, name); if (path != null) { break; } } messagebox.show(path ?? "not found!"); } // non-recursive search 1 level public string findcalendar(mapifolder root, string name) { string path = null; foreach (outlook.mapifolder folder in root.folders) { if (folder.name.equals(name, stringcomparison.invariantcultureignorecase) && (folder.defaultitemtype == olitemtype.olappointmentitem)) { path = folder.folderpath; break; } } homecoming path; }
c# calendar outlook
Comments
Post a Comment