void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector) { Outlook.MailItem tmpMailItem = (Outlook.MailItem)Inspector.CurrentItem; if (Inspector.CurrentItem is Outlook.MailItem) { tmpMailItem = (Outlook.MailItem)Inspector.CurrentItem; bool exists = false; foreach (Office.CommandBar cmd in Inspector.CommandBars) { if (cmd.Name == "EAD") { //exists = true; cmd.Delete(); } } Office.CommandBar newMenuBar = Inspector.CommandBars.Add("EAD", Office.MsoBarPosition.msoBarTop, false, true); buttonOne = (Office.CommandBarButton)newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, missing, missing, true); if (!exists) { buttonOne.Caption = "Scan this mail"; buttonOne.Style = Office.MsoButtonStyle.msoButtonCaption; buttonOne.FaceId = 1983; //Register send event handler buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(buttonOne_Click); newMenuBar.Visible = true; } } }
public void OnStartupComplete(ref System.Array custom) { //----------------------------------------------------------------------------------------------------------------------------------------------------- /* /* * * When outlook is opened it loads a Menu if Outlook plugin is installed. * OpenERP - > Push, Partner ,Documents, Configuration * #1# */ Outlook.Application app = _outlookApplication; try { object omissing = System.Reflection.Missing.Value; menuBar = app.ActiveExplorer().CommandBars.ActiveMenuBar; ConfigManager config = new ConfigManager(); config.LoadConfigurationSetting(); OpenERPOutlookPlugin openerp_outlook = Cache.OpenERPOutlookPlugin; OpenERPConnect openerp_connect = openerp_outlook.Connection; try { if (openerp_connect.URL != null && openerp_connect.DBName != null && openerp_connect.UserId != null && openerp_connect.pswrd != "") { string decodpwd = Tools.DecryptB64Pwd(openerp_connect.pswrd); openerp_connect.Login(openerp_connect.DBName, openerp_connect.UserId, decodpwd); } } catch (Exception) { //just shallow exception } newMenuBar = (Office.CommandBarPopup)menuBar.Controls.Add(MsoControlType.msoControlPopup, omissing, omissing, omissing, true); if (newMenuBar != null) { newMenuBar.Caption = "OpenERP"; newMenuBar.Tag = "My"; btn_open_partner = (Office.CommandBarButton)newMenuBar.Controls.Add(MsoControlType.msoControlButton, omissing, omissing, 1, true); btn_open_partner.Style = MsoButtonStyle.msoButtonIconAndCaption; btn_open_partner.Caption = "Contact"; //Face ID will use to show the ICON in the left side of the menu. btn_open_partner.FaceId = 3710; newMenuBar.Visible = true; btn_open_partner.ClickEvent += new Office.CommandBarButton_ClickEventHandler(this.btn_open_partner_Click); //Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_partner_Click); btn_open_document = (Office.CommandBarButton)newMenuBar.Controls.Add(MsoControlType.msoControlButton, omissing, omissing, 2, true); btn_open_document.Style = MsoButtonStyle.msoButtonIconAndCaption; btn_open_document.Caption = "Documents"; //Face ID will use to show the ICON in the left side of the menu. btn_open_document.FaceId = 258; newMenuBar.Visible = true; btn_open_document.ClickEvent += new Office.CommandBarButton_ClickEventHandler(this.btn_open_document_Click); btn_open_configuration_form = (Office.CommandBarButton)newMenuBar.Controls.Add(MsoControlType.msoControlButton, omissing, omissing, 3, true); btn_open_configuration_form.Style = MsoButtonStyle.msoButtonIconAndCaption; btn_open_configuration_form.Caption = "Configuration"; //Face ID will use to show the ICON in the left side of the menu. btn_open_configuration_form.FaceId = 5644; newMenuBar.Visible = true; btn_open_configuration_form.ClickEvent += new Office.CommandBarButton_ClickEventHandler(this.btn_open_configuration_form_Click); } } catch (Exception ex) { string message = string.Format("An error occured.{0}{0}{1}", Environment.NewLine, ex.Message); MessageBox.Show(message, "OPENERP-Initialize menu", MessageBoxButtons.OK, MessageBoxIcon.Error); } }