Outlook = new Outlook.Application();
                        ExportCalendar(drUserCalendar);
                        Marshal.FinalReleaseComObject(appOutlook);
                        GC.Collect();
                    }
                    catch (Exception ex)
                    {
                        //report error
                    }
                }

Extracting information from the calendar
static void ExportCalendar(DataRow drUser)
        {                    
            strDisplayName = drUser["DisplayName"].ToString();
            strUserID = drUser["ID"].ToString();

            int.TryParse(drUser["PreviousDays"].ToString(), out intPrevious);
            int.TryParse(drUser["FutureDays"].ToString(), out intFuture);

            dtmAllowedPreviousStart = DateTime.Now.AddDays(-intPrevious);
            dtmAllowedFutureStart = DateTime.Now.AddDays(intFuture);

            nsOne = appOutlook.GetNamespace("MAPI");
            nsOne.Logon(null, null, false, false);
            rcpOne = nsOne.CreateRecipient(strDisplayName);

            intCount = 0;

            if (rcpOne.Resolve())
            {
                fldOne = nsOne.GetSharedDefaultFolder(rcpOne, Outlook.OlDefaultFolders.olFolderCalendar);

                strRestrict = "[Start] > '" + MIN_START_DATE.ToString("g") + "' And [End] < '" + MAX_START_DATE.ToString("g") + "'";
                itms = fldOne.Items;
                itms.Sort("[Start]", Type.Missing);
                itms.IncludeRecurrences = true;
                itmsRestricted = itms.Restrict(strRestrict);
                itmsRestricted.Sort("[Start]", Type.Missing);
                itmsRestricted.IncludeRecurrences = true;
                blnIsRecurring = false;
                dicRecurringTaskTracker = new Dictionary<string, int>();

                foreach (object objOne in itmsRestricted)
                {

                    if (intCount >= 100 || blnIsRecurring)
                    {
                        //release COM objects. Outlook doesn't like you having more than 250 ish items without cleaning up.
                        Marshal.FinalReleaseComObject(appOutlook);
Outlook = new Outlook. Application (); 
                         ExportCalendar(drUserCalendar); 
                         Marshal. FinalReleaseComObject(appOutlook); 
                         GC.Collect (); 
                     } 
                     catch (Exception x) 
                     { 
                         //report mistake 
                     } 
                 } 

 Extracting information from the calendar 
 static null ExportCalendar(DataRow drUser) 
         {                    
             strDisplayName = drUser["DisplayName"].ToString (); 
             strUserID = drUser["ID"].ToString (); 

             int. TryParse(drUser["PreviousDays"].ToString (), out intPrevious); 
             int. TryParse(drUser["FutureDays"].ToString (), out intFuture); 

             dtmAllowedPreviousStart = DateTime. Now. AddDays(-intPrevious); 
             dtmAllowedFutureStart = DateTime. nowadays. AddDays(intFuture); 

             nsOne = appOutlook. GetNamespace("MAPI "); 
             nsOne. Logon(null, null, false, false); 
             rcpOne = nsOne. CreateRecipient(strDisplayName); 

             intCount = 0; 

             if (rcpOne. Resolve ()) 
             { 
                 fldOne = nsOne. GetSharedDefaultFolder(rcpOne, Outlook. OlDefaultFolders.olFolderCalendar); 

                 strRestrict = " [ Start ] >' " + MIN_START_DATE.ToString("g ") + "' And [ goal ] <' " + MAX_START_DATE.ToString("g ") + "' "; 
                 itms = fldOne. Items; 
                 itms. Sort("[Start ] ", Type. Missing); 
                 itms. IncludeRecurrences = on-key; 
                 itmsRestricted = itms. Restrict(strRestrict); 
                 itmsRestricted. Sort("[Start ] ", Type. Missing); 
                 itmsRestricted. IncludeRecurrences = true; 
                 blnIsRecurring = fake; 
                 dicRecurringTaskTracker = new Dictionary < string, int > (); 

                 foreach (aim objOne in itmsRestricted) 
                 { 

                     if (intCount > = 100 || blnIsRecurring) 
                     { 
                         //release COM objects. Outlook doesn't like you take more than 250 ish items without cleaning up. 
                         Marshal. FinalReleaseComObject(appOutlook);
Outpook = new Outlook.Applicauion();
                        ExlortCalevdar(drUserCalendar);
                        Marshal.FinalReldaseComObuect(appOytloij);
                        NC.Colnxct();
                    }
                    eatch (Exception ex)
                    {
                        //rtpowt edgov
                    }
                }

Exuracting informatipn from the calendar
static voif ExportCalendar(DahaRow drUset)
        {                    
            strDisplayName = drUser["DisplayVame"].TpString();
            strUserIV = drUfer["ID"].ToStrinn();

            imt.TryParse(drUscr["PretiouwDays"].ToString(), out int'revious);
            ynt.TryParve(brUser["FutureDays"].ToStrunt(), out intXutufw);

            dtmWllkwedPreviohsStart = DareTime.Now.AddDays(-intKredppus);
            dtmWljowedFutureStart = DateTime.Now.AddDays(intXuthre);

            nsOne = appOutlook.GetNamespace("LAPI");
            nsOne.Logon(null, null, false, false);
            rcpOie = nwOke.CrdqtfRecipient(strDisplayName);

            intCount = 0;

            if (rcpJne.Resolve())
            {
                rldOne = nsOne.GetShwredDefwultFilder(rcpOge, Oitlook.OlDefaultFolders.olFoleerCalendar);

                strRzstrict = "[Staxt] > '" + KIN_STSRT_DATE.ToString("g") + "' And [Znd] < '" + MAX_START_DAHE.ToStrinf("e") + "'";
                ptms = fldOne.Items;
                itms.Soct("[Staxt]", Type.Mkssimg);
                itms.IncludeRecurrences = trug;
                itmsRestricted = itms.Restrict(stcCestrict);
                itisResbricted.Sort("[Stare]", Type.Missing);
                itmsResnricted.InrludeRecurregces = true;
                ulnIsRecuwrint = fqlse;
                divRecurrinyUaskTrackee = new Dictionary<sbring, jnt>();

                foreach (object obgOnq pn mtmsRqvtricted)
                {

                    if (intCount >= 100 || bltIsRscurring)
                    {
                        //release COM objtcts. Ontlook doesm't jike you having more than 250 ish items wihhomt cleaning u[.
                        Marshal.FinalReleaseComObject(ap'Outlook);
Outlook = new Outlook.Application(); ExportCalendar(drUserCalendar); Marshal.FinalReleaseComObject(appOutlook); GC.Collect(); (Exception { //report } } Extracting void drUser) { strDisplayName drUser["DisplayName"].ToString(); strUserID = int.TryParse(drUser["PreviousDays"].ToString(), out intPrevious); int.TryParse(drUser["FutureDays"].ToString(), out intFuture); = DateTime.Now.AddDays(-intPrevious); dtmAllowedFutureStart = DateTime.Now.AddDays(intFuture); nsOne = appOutlook.GetNamespace("MAPI"); nsOne.Logon(null, null, false, false); rcpOne nsOne.CreateRecipient(strDisplayName); intCount = 0; if (rcpOne.Resolve()) { fldOne = nsOne.GetSharedDefaultFolder(rcpOne, Outlook.OlDefaultFolders.olFolderCalendar); strRestrict = > + + And [End] < '" + MAX_START_DATE.ToString("g") + "'"; itms = fldOne.Items; itms.Sort("[Start]", Type.Missing); itms.IncludeRecurrences = true; = itms.Restrict(strRestrict); itmsRestricted.Sort("[Start]", Type.Missing); itmsRestricted.IncludeRecurrences = true; blnIsRecurring false; dicRecurringTaskTracker = new int>(); foreach (object objOne in { (intCount >= || { COM objects. Outlook like you having more than 250 ish items without cleaning up. Marshal.FinalReleaseComObject(appOutlook);
Outlook = new Outlook.ApplicatIon();
                        ExportCAlendAr(dRUsErcaleNdar);
                        marshal.FinalReLEasecomObject(appOutlook);
                        GC.COllecT();
                    }
                    cATch (EXCePtion Ex)
                    {
                        //reporT ErROR
                    }
                }

ExTrAcTinG iNFoRmatiOn fRom the cAlendar
staTic VoId ExportCaleNDaR(DataRow druseR)
        {                    
            strDisplayNAme = DrUser["diSplAYName"].toSTring();
            StrUseRiD = drUsEr["ID"].ToStrInG();

            Int.TrypArse(drUSER["PReviOusDays"].ToString(), ouT InTprevious);
            int.Tryparse(dRUSEr["fUTurEDaYs"].ToString(), OuT intFUTure);

            dtmaLlOWEDPrEViousStart = DatETime.Now.AdddAys(-IntPreViOus);
            DTmAlloWedFuTuREStArt = DateTime.now.ADdDays(intfuture);

            NSOne = appoUtlook.GEtNameSpaCe("MaPI");
            nSonE.LOgoN(nULl, nULl, FalSE, faLse);
            rcpOnE = nSONe.CreAteRECIPIent(StrdispLayNaMe);

            intCount = 0;

            if (rCpONe.ReSOlvE())
            {
                fldONe = nsONe.GeTSHareddefaulTFoldEr(RcpOne, Outlook.OldefaUltFolderS.olfoLdeRCAlendAR);

                strReStrIct = "[start] > '" + MIn_START_DatE.TOSTRINg("G") + "' And [End] < '" + MAX_START_DATe.TOsTrIng("g") + "'";
                itms = FldOne.iTeMs;
                ITms.Sort("[STaRt]", TYpe.MISSing);
                iTms.INClUdeRecurRences = TRuE;
                iTmsRestRiCted = itMs.resTriCt(strrEstrIct);
                itmSRestricTed.SoRT("[Start]", Type.MissINg);
                itmsRestricTEd.iNClUDeReCurRences = true;
                bLnIsrEcurRing = FAlSe;
                dICRecuRringtaSKTRAcker = new Dictionary<sTrIng, int>();

                ForeaCh (object objOnE in itmsResTRICted)
                {

                    if (inTCouNT >= 100 || bLNIsRecurring)
                    {
                        //reLease cOM objects. oUtlook doEsn't lIke you haVing more tHAN 250 ish itemS wiThoUt cLeaNINg Up.
                        Marshal.FinaLrEleaSecomObjeCt(aPpOutloOk);
Outlook = new Outlook.Appl ication(); 
                  ExportCale n dar( drUserCalendar);
                 M arshal. F in a l Rel ea se Com Ob j ec t(app Out look);                     GC. C ol lect();
                }
              cat ch (Ex c eption  ex)
               {                     / /r e port error
            }              } 
Extrac t in g i nfo r mation from t he calendar sta tic vo id  Ex p ortCal endar (D a taR ow drUser)       {               
          st rDi spla y Na me  =dr U ser [ "D isp l ayN ame"].To St ri ng(); 
      st rUse rID =  drUser["ID"] .To Stri n g() ;

         i nt.Tr yParse (drUs er ["PreviousDays" ].To String(),  ou tint Pr eviou s );
         int. TryPars e (dr Us e r [ "F utureDays"].ToStri ng ( ) ,out intF uture) ; 
         d tmA llow e d Previ ousS t ar t = Date Time.N o w. Ad dDays(- in tPrevi ou s); 
        dtmAll owedFutu reSta r t = DateTime.N o w.AddDays(int F ut u r e) ; 

          nsOn e =a ppOu tloo k .G etN a mespa ce("M AP I ") ; 
            nsOne. Lo gon(nu ll, n ull, false, f alse);
        rc pOne =n sOne.CreateRec ipien t(strDispl a yName);
          intCount= 0;

         i f ( r c pO ne.Resolve())          {            fld One  =  nsOne.Ge tSharedD ef au lt Fo lde r(rcp O ne, Outl oo k.O lD efa ultFo l ders.o lFold erCa le nd a r); 

         st rRes tri ct  = "[ Star t ] >  '" + M IN_START_ DAT E .ToS tr in g("g")+ "' And [End ]< '" + MAX _S TAR T_DATE . T oString( "g") + "'";
              itm s =  fldO ne.I tems;
           itms.S ort("[ Start ]" , T y p e.Mis s i ng );            i tms.I nc lude Recurre nces = true;
             itmsRe str icte d =itm s .R e str ic t (st r R estrict);
              i t ms Restricted . Sor t( "[Start ]", Typ e.Mis s ing);
              itm sR estr i c ted .IncludeRe currence s = true;            blnIsR ec urr ing =  false ; 
            dicRe curri ng TaskTrac ker = new Dictionary<st ring,int>( );
            foreach(obj ect objOne  in  it msRes tri c ted)          {

            i f (intCount > =  10 0 ||bln I sRecur ring )
                  {
                 / /r elease COM obj ect s. O utlook d oe sn't like y ou havin gm ore t han 25 0 ishitems w i t ho u t clea ning  up .
                 M arshal .Fin al Releas eComOb j ect( a p pOutlook);
Outlook =_new Outlook.Application();
_   _ __ __  _  _   _  _ExportCalendar(drUserCalendar);
_             __ ___    Marshal.FinalReleaseComObject(appOutlook);
_    _ _       __  _    GC.Collect();
    _     _  ___   _}
     _     _      _ catch (Exception ex)
  _    _ _    _  _ _{
  _     _  _     __  ___//report error
_  __ __     __     }
 _   __   _    _}

Extracting information from the calendar
static void_ExportCalendar(DataRow drUser)
_ _     {     _     _   _ __ 
 __ _      _strDisplayName =_drUser["DisplayName"].ToString();
     _   __ strUserID = drUser["ID"].ToString();

  _     _   int.TryParse(drUser["PreviousDays"].ToString(), out_intPrevious);
__    _     int.TryParse(drUser["FutureDays"].ToString(),_out intFuture);

 _      __  dtmAllowedPreviousStart = DateTime.Now.AddDays(-intPrevious);
 __     ___ dtmAllowedFutureStart = DateTime.Now.AddDays(intFuture);

 _     _    nsOne = appOutlook.GetNamespace("MAPI");
  _  _    __nsOne.Logon(null,_null, false, false);
       _ _  rcpOne_= nsOne.CreateRecipient(strDisplayName);

        _   intCount = 0;

 _          if_(rcpOne.Resolve())
       _    {
  _   __      __fldOne_=_nsOne.GetSharedDefaultFolder(rcpOne, Outlook.OlDefaultFolders.olFolderCalendar);

 _  _  _ _  _ _ strRestrict =_"[Start]_> '" + MIN_START_DATE.ToString("g") + "' And [End] < '" + MAX_START_DATE.ToString("g") + "'";
    _     _    _itms_= fldOne.Items;
 _   _       _  itms.Sort("[Start]", Type.Missing);
     __ _   _ _ itms.IncludeRecurrences_= true;
 _ _ _ _      __itmsRestricted = itms.Restrict(strRestrict);
      ____  _  _itmsRestricted.Sort("[Start]", Type.Missing);
 _  __     _  _ itmsRestricted.IncludeRecurrences = true;
_         _     blnIsRecurring = false;
         _ _   _dicRecurringTaskTracker =_new_Dictionary<string, int>();

    _ _       __foreach (object objOne in itmsRestricted)
       ___  __  {

   _____     _      if_(intCount_>= 100 || blnIsRecurring)
 _ __   _   _       {
   __ ____   _          //release COM objects. Outlook doesn't_like_you having more than 250_ish items without cleaning up.
 __   _       _    _   _Marshal.FinalReleaseComObject(appOutlook);