示例#1
0
        /// <summary>
        ///<c>ThisAddIn_Startup</c>  Outlook startup event
        /// This Event is  executed when outlook starts(outlook is opened)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            try
            {

                //declare and initialize variables used for the Instant PLUS check
                Int32 result = 0;

                string filePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\ITOPIA\\SharePoint Link 2010\\", "SharePoint Link.xml");

                //Make the call to Instant PLUS and store the result
                result = Ip2LibManaged.CallInstantPLUS(Ip2LibManaged.FLAGS_NONE, "30820274020100300D06092A864886F70D01010105000482025E3082025A02010002818100BA81817A32C249909671428137ECFC2AEF45E5F746C218550C2191F525A15E65DCD87CAD8B46EB870E55897D1D185B9D88BCDDB6D44CB8B9DDFD7DB4948E8CF91743377F31DB733438828CA0EC3176D8650C8F4B77578E60285F55049D9A707C61FF75C7C626492415BBCBE8058E4F220826A356F1C50B29C92B354C61BEF21F0201110281800AF88F254E47A9F97242E5CB5DA4874DD1D6EF68E60B6AD7D389810E6BA0149C94853482ADD6FECBB58C8F9DF2A71472ADB0C1BF75E665381C1DF855EA9EF93BBA5432731B506EDFE944C217EB09F27AA8203C7D7310D78995A9549690836B313CDCD0B2FA6AD79576977EB44B33D46577E9EA6939DCF8388761E25C3FADF9B1024100F3F70346EEA01874427576DFF5136A9B3A1AB4522ADD2073669376540C6CE65A1A613D0F4754FAD4C8DA70D3F5F5F0D4DAF97B0CF49D9BDA0ECE0F8F46A19BBF024100C3B4DA9372E3FDE1787C322A5B74F21800CDD6A4A85C1DC9D18D40B0F8736BDD3CF45CD5DDB8FD626CD1F11B1127439036A4974D257AF38EBCDD1D9CE08FC1A1024100AC35E43211DA6B9D5C16AE43BC0DB4A9CEA9703A00239E6F93B36295AE6AFCF44EDB3A28E70ECF2CCA039AEFF8E9D72CD6CE38BDD9D8AA3F91FADDCE8C35D75902405095C369E40386A8228D7E1170F3EB370F63D0DA63713971382B1AA3392077B57373ADC1796A4A3796385438525B762C52BC3E4CF150BEA42FA6577CD4EFE65102405162E2024CE04279E92731B490BE2431758FA6D032B0DB85B2AC782956832095800B4A8AB7D6FC1DB905CA38508FC3CC49994A48940CF9BB5761C07A9289D492", filePath);

                if (11574 != result)
                {
                    //this.Close();
                    //this.Application.ActiveExplorer().Close();
                    //this.Application.Quit();
                    return;
                }

                isAuthorized = true;

                #region Add-in Express Regions generated code - do not modify
                this.FormsManager = AddinExpress.OL.ADXOlFormsManager.CurrentInstance;
                this.FormsManager.OnInitialize +=
                    new AddinExpress.OL.ADXOlFormsManager.OnComponentInitialize_EventHandler(this.FormsManager_OnInitialize);
                //this.FormsManager.ADXBeforeFolderSwitchEx +=
                //     new AddinExpress.OL.ADXOlFormsManager.BeforeFolderSwitchEx_EventHandler(FormsManager_ADXBeforeFolderSwitchEx);

                this.FormsManager.Initialize(this);
                #endregion

                //DateTime dtExpiredDate = new DateTime(2010, 08, 05);
                //DateTime dtWorkingDate = DateTime.Now;
                //TimeSpan t = new TimeSpan();
                //t = dtExpiredDate.Subtract(dtWorkingDate);

                //if (t.Days < 30 && t.Days >= 0)
                //{

                //outlookObj = new Outlook.Application();

                OutlookObj = Globals.ThisAddIn.Application;
                //Gte MAPI Name space
                outlookNameSpace = OutlookObj.GetNamespace("MAPI");

                //Get inbox folder
                Outlook.MAPIFolder oInBox = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
                //Get current user details to save the xml file based on user
                string userName = outlookNameSpace.DefaultStore.DisplayName;
                userName = userName.Replace("-", "_");
                userName = userName.Replace(" ", "");
                UserLogManagerUtility.UserXMLFileName = userName;

                //Get parent root folder
                Outlook.MAPIFolder olMailRootFolder = (Outlook.MAPIFolder)oInBox.Parent;
                //Get all folder
                oMailRootFolders = olMailRootFolder.Folders;
                //Create folder remove event
                oMailRootFolders.FolderRemove += new Microsoft.Office.Interop.Outlook.FoldersEvents_FolderRemoveEventHandler(oMailRootFolders_FolderRemove);

                //Set inbox folder as default

                try
                {

                    OutlookObj.ActiveExplorer().CurrentFolder = oInBox;
                    addinExplorer = this.Application.ActiveExplorer();
                    addinExplorer.BeforeItemPaste += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_BeforeItemPasteEventHandler(addinExplorer_BeforeItemPaste);
                    //Create folder Switch event
                    addinExplorer.FolderSwitch += new Microsoft.Office.Interop.Outlook.ExplorerEvents_10_FolderSwitchEventHandler(addinExplorer_FolderSwitch);

                    //crete folder context menu disply
                    this.Application.FolderContextMenuDisplay += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHandler(Application_FolderContextMenuDisplay);

                    this.Application.ContextMenuClose += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ContextMenuCloseEventHandler(Application_ContextMenuClose);

                    strParentMenuTag = strParentMenuName;
                    // Removing the Existing Menu Bar
                    //  RemoveItopiaMenuBarIfExists(strParentMenuTag);
                    // Adding The Menu Bar Freshly
                    //  CreateParentMenu(strParentMenuTag, strParentMenuName);
                    myTargetFolder = oInBox;
                    CreateAddEventOnFolders();
                    //CreateDefaultAddEventOnFolders();
                    //Create outlook explorer wrapper class
                    OutlookWindow = new OutlookExplorerWrapper(OutlookObj.ActiveExplorer());
                    OutlookWindow.Close += new EventHandler(OutlookWindow_Close);

                    ((Outlook.ExplorerEvents_Event)addinExplorer).BeforeFolderSwitch += new Microsoft.Office.Interop.Outlook.ExplorerEvents_BeforeFolderSwitchEventHandler(ThisAddIn_BeforeFolderSwitch);

                    oMailRootFolders.FolderChange += new Outlook.FoldersEvents_FolderChangeEventHandler(oMailRootFolders_FolderChange);

                    foreach (Outlook.MAPIFolder item in oMailRootFolders)
                    {

                        try
                        {
                            item.Folders.FolderChange -= new Outlook.FoldersEvents_FolderChangeEventHandler(oMailRootFolders_FolderChange);

                        }
                        catch (Exception)
                        {
                        }
                        item.Folders.FolderChange += new Outlook.FoldersEvents_FolderChangeEventHandler(oMailRootFolders_FolderChange);

                    }

                    Outlook.Items activeDroppingFolderItems;

                    activeDroppingFolderItems = oInBox.Items;

                    userOptions = UserLogManagerUtility.GetUserConfigurationOptions();
                    currentFolderSelected = oInBox.Name;
                    currentFolderSelectedGuid = oInBox.EntryID;
                }
                catch (Exception ex)
                {
                    ListWebClass.Log(ex.Message, true);
                }

                // }

            }
            catch (Exception ex)
            {
                EncodingAndDecoding.ShowMessageBox("StartUP", ex.Message, MessageBoxIcon.Error);
            }

            /// <summary>
            //code written by Joy
            ///initializes the object of timer
            /// </summary>

            System.Threading.AutoResetEvent reset = new System.Threading.AutoResetEvent(true);

            timer = new System.Threading.Timer(new System.Threading.TimerCallback(doBackgroundUploading), reset, 180000, 180000);

            GC.KeepAlive(timer);
            form = new Form();
            form.Opacity = 0.01;
            form.Show();
            form.Visible = false;
        }
示例#2
0
 /// <summary>
 /// <c>OutlookWindow_Close</c>  Event Handler
 /// Outlook close window event.
 /// This event is fired when an outlook window is closed.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OutlookWindow_Close(object sender, EventArgs e)
 {
     /////////////////////////////////Modified on 16.08.2012///////////////////////////////////////////
        ///code written by Joy
        ///disposes the timer when outlook is being closed
     timer.Dispose();
     /////////////////////////////////Modified on 16.08.2012///////////////////////////////////////////
     SetOriginalUrls();
     try
     {
         OutlookWindow = (OutlookExplorerWrapper)sender;
         OutlookWindow.Close -= new EventHandler(OutlookWindow_Close);
     }
     catch { }
 }