visual studio - How to display shared calendar in outlook using c#? -
i want'to display shared calendar. search on web , find code:
static void main(string[] args) { outlook.application objolapp; outlook.mapifolder objfolder; outlook.explorer objexplorer; outlook.mapifolder objsubfolder; outlook.appointmentitem objcalenderitem; outlook.folders objoutlookfolders; int intfolderctr; int intsubfolderctr; int intappointmentctr; // >> initialize base objects objolapp = new outlook.application(); objoutlookfolders = objolapp.session.folders; // >> loop through pst files added n outlook (intfolderctr = 1; intfolderctr <= objoutlookfolders.count; intfolderctr++) { objfolder = objoutlookfolders[intfolderctr]; objexplorer = objfolder.getexplorer(); // >> loop through folders in pst file (intsubfolderctr = 1; intsubfolderctr <= objexplorer.currentfolder.folders.count; intsubfolderctr++) { objsubfolder = objexplorer.currentfolder.folders[intsubfolderctr]; // >> check if folder contains appointment items if (objsubfolder.defaultitemtype == outlook.olitemtype.olappointmentitem) { // >> loop through appointment items (intappointmentctr = 1; intappointmentctr <= objsubfolder.items.count; intappointmentctr++) { // >> teh calender item calender folder objcalenderitem = objsubfolder.items[intappointmentctr]; // >> process appointment item accordingly console.writeline(objcalenderitem.subject); console.writeline(objcalenderitem.location + "," + objcalenderitem.start.tolongdatestring()); console.writeline(); console.writeline(); } } } } // >> close application // objolapp.quit(); // >> release com object system.runtime.interopservices.marshal.releasecomobject(objolapp); objolapp = null; console.readline(); }
but it's see appointment.
i want see shared calendar. because set meeting don't know idea other person's busy or free. how can display other's calendar?
editing :
i changed line
objoutlookfolders = objolapp.session.folders;
with
objoutlookfolders = ons.getshareddefaultfolder(orep, oldefaultfolders.olfoldercalendar).folders;
and add this
namespace ons = objolapp.getnamespace("mapi"); recipient orep = ons.createrecipient(objolapp.session.currentuser.name);
but still error.
new version
static void main(string[] args) { outlook.application objolapp; outlook.mapifolder objfolder; outlook.explorer objexplorer; outlook.mapifolder objsubfolder; outlook.appointmentitem objcalenderitem; outlook.folders objoutlookfolders; int intfolderctr; int intsubfolderctr; int intappointmentctr; // >> initialize base objects objolapp = new outlook.application(); namespace ons = objolapp.getnamespace("mapi"); recipient orep = ons.createrecipient(objolapp.session.currentuser.name); orep.resolve(); //if (orep.resolved) objoutlookfolders = ons.getshareddefaultfolder(orep, oldefaultfolders.olfoldercalendar).folders; //else // objoutlookfolders = objolapp.session.folders; // >> loop through pst files added n outlook (intfolderctr = 1; intfolderctr <= objoutlookfolders.count; intfolderctr++) { objfolder = objoutlookfolders[intfolderctr]; objexplorer = objfolder.getexplorer(); // >> loop through folders in pst file (intsubfolderctr = 1; intsubfolderctr <= objexplorer.currentfolder.folders.count; intsubfolderctr++) { objsubfolder = objexplorer.currentfolder.folders[intsubfolderctr]; // >> check if folder contains appointment items if (objsubfolder.defaultitemtype == outlook.olitemtype.olappointmentitem) { // >> loop through appointment items (intappointmentctr = 1; intappointmentctr <= objsubfolder.items.count; intappointmentctr++) { // >> teh calender item calender folder objcalenderitem = objsubfolder.items[intappointmentctr]; // >> process appointment item accordingly console.writeline(objcalenderitem.subject); console.writeline(objcalenderitem.location + "," + objcalenderitem.start.tolongdatestring()); console.writeline(); console.writeline(); } } } } // >> close application // objolapp.quit(); // >> release com object system.runtime.interopservices.marshal.releasecomobject(objolapp); objolapp = null; console.readline(); }
please me.. i'm still working. did not .
use namespace.getshareddefaultfolder open other user's default calendar folder.
Comments
Post a Comment