c# - How to add Outlook toolbar under the subject line? -


i need write outlook 2003-2010 plugin using c# adds two buttons message ribbon bar (#1 on picture) , several buttons toolbar or form region under "subject" line (#2 on picture).

see image here

currently managed add button ribbon toolbar, appears in "add-ins" ribbon bar. how add buttons "message" ribbon bar?

and how add toolbar #2 ? have no clue how add it.

please me!

i have follwing code:

using system; using system.collections.generic; using system.linq; using system.text; using system.xml.linq; using outlook = microsoft.office.interop.outlook; using office = microsoft.office.core; using system.windows.forms;  namespace sendlatertoolbar {     public partial class thisaddin     {         office.commandbar newtoolbar;         office.commandbarbutton firstbutton;         office.commandbarbutton secondbutton;         outlook.explorers selectexplorers;         outlook.inspectors inspectors;         office.commandbarbutton _objemailtoolbarbutton;          private void thisaddin_startup(object sender, system.eventargs e)         {             selectexplorers = this.application.explorers;             inspectors = this.application.inspectors;             selectexplorers.newexplorer += new outlook.explorersevents_newexplorereventhandler(newexplorer_event);             inspectors.newinspector += new microsoft.office.interop.outlook.inspectorsevents_newinspectoreventhandler(addtoemail);             addtoolbar();         }          private void newexplorer_event(outlook.explorer new_explorer)         {             ((outlook._explorer)new_explorer).activate();             newtoolbar = null;             addtoolbar();         }          private void thisaddin_shutdown(object sender, system.eventargs e)         {          }          private void addtoolbar()         {              if (newtoolbar == null)             {                 office.commandbars cmdbars =                     this.application.activeexplorer().commandbars;                 newtoolbar = cmdbars.add("newtoolbar",                     office.msobarposition.msobartop, false, true);             }             try             {                 office.commandbarbutton button_1 =                     (office.commandbarbutton)newtoolbar.controls                     .add(1, missing, missing, missing, missing);                 button_1.style = office                     .msobuttonstyle.msobuttoncaption;                 button_1.caption = "button 1";                 button_1.tag = "button1";                 if (this.firstbutton == null)                 {                     this.firstbutton = button_1;                     firstbutton.click += new office.                         _commandbarbuttonevents_clickeventhandler                         (buttonclick);                 }                  office.commandbarbutton button_2 = (office                     .commandbarbutton)newtoolbar.controls.add                     (1, missing, missing, missing, missing);                 button_2.style = office                     .msobuttonstyle.msobuttoncaption;                 button_2.caption = "button 2";                 button_2.tag = "button2";                 newtoolbar.visible = true;                 if (this.secondbutton == null)                 {                     this.secondbutton = button_2;                     secondbutton.click += new office.                         _commandbarbuttonevents_clickeventhandler                         (buttonclick);                 }             }             catch (exception ex)             {                 messagebox.show(ex.message);             }         }          private void addtoemail(microsoft.office.interop.outlook.inspector inspector)         {             outlook.mailitem _objmailitem = (outlook.mailitem)inspector.currentitem;              if (inspector.currentitem outlook.mailitem)             {                 _objmailitem = (outlook.mailitem)inspector.currentitem;                 bool isexists = false;                  foreach (office.commandbar _objcmd in inspector.commandbars)                 {                     if (_objcmd.name == "myemailtoolbar")                     {                         isexists = true;                         _objcmd.delete();                     }                 }                  office.commandbar _objcommandbar = inspector.commandbars.add("myemailtoolbar", office.msobarposition.msobarbottom, false, true);                 _objemailtoolbarbutton = (office.commandbarbutton)_objcommandbar.controls.add(office.msocontroltype.msocontrolbutton, 1, missing, missing, true);                  if (!isexists)                 {                     _objemailtoolbarbutton.caption = "my email toolbar button";                     _objemailtoolbarbutton.style = office.msobuttonstyle.msobuttoniconandcaptionbelow;                     _objemailtoolbarbutton.faceid = 500;                     _objemailtoolbarbutton.click += new office._commandbarbuttonevents_clickeventhandler(_objemailtoolbarbutton_click);                     _objcommandbar.visible = true;                 }             }         }           private void buttonclick(office.commandbarbutton ctrl, ref bool cancel)         {             messagebox.show("you clicked: " + ctrl.caption);         }          private void _objemailtoolbarbutton_click(office.commandbarbutton ctrl, ref bool cancel)         {             messagebox.show("my email toolbar ...");         }          #region vsto generated code          /// <summary>         /// required method designer support - not modify         /// contents of method code editor.         /// </summary>         private void internalstartup()         {             this.startup += new system.eventhandler(thisaddin_startup);             this.shutdown += new system.eventhandler(thisaddin_shutdown);         }          #endregion     } 

}

the custom buttons creating meant hosted on commandbar control outlook 2000-2003. can use ribbon designer in vsto project add custom ribbon group message tab (the id tabnewmailmessage).

unfortunately, there's no way inject custom ui between message body , address header. can use task panes , form regions must go above header or left, right , bottom of message body.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -