private void CurrentExplorer_Event() { Outlook.MAPIFolder selectedFolder = olApp.ActiveExplorer().CurrentFolder; Outlook.Selection oSel = olExplorer.Selection; /* if (oSel.Count != 1) * { * MessageBox.Show("Please select only one message for PKCS#7 structure inspection!"); * return; * } * */ System.Collections.IEnumerator i = oSel.GetEnumerator(); i.MoveNext(); Object selObject = (Outlook.MailItem)i.Current; if (selObject is Outlook.MailItem) { Outlook.MailItem mailItem = (selObject as Outlook.MailItem); try { bool doIt = false; SafeMailItem smi = new SafeMailItemClass(); smi.Item = mailItem; mailID = mailItem.EntryID; /*Outlook.NameSpace ns = olApp.GetNamespace("MAPI"); * * Outlook.MAPIFolder f = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); * Outlook.Folders folders = f.Folders; * foreach (Outlook.Folder fol in folders) { * if (fol.Name == "TEST") { * // * break; * } * * } * */ // @"\\Mailbox - Dauberschmidt, Markus\Inbox\TEST" } catch (Exception ie) { MessageBox.Show("Exception: " + ie.Message); } } }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { // Define the Old Menu Bar PacktOldMenuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; // Define the new Menu Bar into the existing menu bar PacktNewMenuBar = (Office.CommandBarPopup)PacktOldMenuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false); //If PacktNewMenuBar not found then the code will add it if (PacktNewMenuBar != null) { // Set caption for the Menu PacktNewMenuBar.Caption = "Analyze PKCS#7 structure"; // Tag string value passing PacktNewMenuBar.Tag = strMenuString; // Assigning button type PacktButton1 = (Office.CommandBarButton)PacktNewMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); // Setting up the button style PacktButton1.Style = Office.MsoButtonStyle.msoButtonIconAndCaptionBelow; // Set button caption PacktButton1.Caption = "Analyze PKCS#7 structure"; // Set the menu visible PacktNewMenuBar.Visible = true; } // Verify the PacktCustomToolBar exist and add to the application if (PacktCustomToolBar == null) { // Adding the commandbar to Active explorer Office.CommandBars PacktBars = this.Application.ActiveExplorer().CommandBars; // Adding PacktCustomToolBar to the commandbars PacktCustomToolBar = PacktBars.Add("NewPacktToolBar", Office.MsoBarPosition.msoBarTop, false, true); } // Adding button to the custom tool bar Office.CommandBarButton MyButton1 = (Office.CommandBarButton)PacktCustomToolBar.Controls.Add(1, missing, missing, missing, missing); // Set the button style MyButton1.Style = Office.MsoButtonStyle.msoButtonCaption; // Set the caption and tag string MyButton1.Caption = "Analyze PKCS#7 structure"; MyButton1.Tag = "Analyze PKCS#7 structure"; if (this.PacktButtonA == null) { // Adding the event handler for the button in the toolbar this.PacktButtonA = MyButton1; PacktButtonA.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick); } olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNs = olApp.GetNamespace("MAPI"); olExplorer = olApp.ActiveExplorer(); // olExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event); }
/// <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; }