2014-04-23 2 views
0

메시지 막대 (그림 # 1)에 두 개의 단추와 단추 또는 양식 줄 "제목"줄 아래에 여러 개의 단추를 추가하는 C# 2 그림에서). 제목 줄 아래에 Outlook 도구 모음을 추가하는 방법은 무엇입니까?

See image here

현재 나는 리본 도구 모음에 단추를 추가하는 데 성공,하지만 "추가 기능"리본 표시 줄에 나타납니다. "Message"리본 바에 어떻게 버튼을 추가합니까?

그리고 툴바 # 2를 어떻게 추가합니까? 현재 추가하는 방법에 대한 단서가 없습니다.

도와주세요!

나는 지금 follwing을 코드를 가지고 :

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 is 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 for Designer support - do not modify 
     /// the contents of this method with the code editor. 
     /// </summary> 
     private void InternalStartup() 
     { 
      this.Startup += new System.EventHandler(ThisAddIn_Startup); 
      this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); 
     } 

     #endregion 
    } 

}

답변

0

하여 Outlook 2,000에서 2,003 사이의 명령 모음 컨트롤을 호스팅하는 의미 생성하는 사용자 정의 버튼. VSTO 프로젝트에서 리본 디자이너를 사용하여 메시지 탭에 사용자 지정 리본 그룹을 추가 할 수 있습니다 (ID는 TabNewMailMessage 임).

불행히도 메시지 본문과 주소 헤더간에 맞춤 UI를 삽입 할 수있는 방법이 없습니다. 작업 창 및 양식 영역을 사용할 수 있지만 머리글 또는 메시지 본문의 왼쪽, 오른쪽 및 아래쪽으로 이동해야합니다.

+0

확인. 두 번째 문제는 불행하게도 사실입니다. 도와 줘서 고마워. –

관련 문제