2016-06-08 3 views
-2

C#을 사용하여 Outlook에서 메시지를 리콜 할 수있는 코드를 작성하려고합니다. Outlook에 사용자 정의 탭이 있고 버튼이 있습니다. 단추를 클릭하여 코드를 작성해야합니다 (보낸 메일 선택 후). Outlook의 리콜 메시지 기능을 호출해야합니다.Outlook 리콜 메시지 C#

메시지를 리콜하기위한 한계를 알고 있습니다. 그러나 여전히 조직은 이것을 계속하기를 원합니다. 리콜 메시지 버튼을 호출하는 사람이 누구인지 알려주십시오. 감사합니다 감사합니다, 나는 명령 모음으로 전망 2010 C#에서 아래의 코드를 컴파일 어떻게

답변

0

나는 직접 답변을 찾았습니다.

1: private void btnRecall_Click(object sender, RibbonControlEventArgs e) 
    2:  { 
    3:   Outlook.MailItem oldMailItem = GetMailItem(e); 
    4:   Inspector inspect= oldMailItem.GetInspector; 
    5:   inspect.Display(false); 
    6:   inspect.CommandBars.ExecuteMso("RecallThisMessage");   
    7:  } 
    8: 
    9: private Microsoft.Office.Interop.Outlook.MailItem GetMailItem(RibbonControlEventArgs e) 
    10:  { 
    11:   // Check to see if a item is select in explorer or we are in inspector. 
    12:   if (e.Control.Context is Microsoft.Office.Interop.Outlook.Inspector) 
    13:   { 
    14:    Microsoft.Office.Interop.Outlook.Inspector inspector = (Microsoft.Office.Interop.Outlook.Inspector)e.Control.Context; 
    15: 
    16:    if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.MailItem) 
    17:    { 
    18:     return inspector.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem; 
    19:    } 
    20:   } 
    21: 
    22:   if (e.Control.Context is Microsoft.Office.Interop.Outlook.Explorer) 
    23:   { 
    24:    Microsoft.Office.Interop.Outlook.Explorer explorer = (Microsoft.Office.Interop.Outlook.Explorer)e.Control.Context; 
    25: 
    26:    Microsoft.Office.Interop.Outlook.Selection selectedItems = explorer.Selection; 
    27:    if (selectedItems.Count != 1) 
    28:    { 
    29:     return null; 
    30:    } 
    31: 
    32:    if (selectedItems[1] is Microsoft.Office.Interop.Outlook.MailItem) 
    33:    { 
    34:     return selectedItems[1] as Microsoft.Office.Interop.Outlook.MailItem; 
    35:    } 
    36:   } 
    37: 
    38:   return null; 
    39:  } 
-1

Option Explicit Sub Recall() Dim SendItem As Object Dim olItem As 
Outlook.MailItem Dim olInsp As Outlook.Inspector 

    '// Selected item in Sent Items folder Set SendItem = 
ActiveExplorer.Selection.Item(1) 

    If TypeName(SendItem) = "MailItem" Then 
    Set olItem = SendItem 
    Set olInsp = olItem.GetInspector 
    '// Execute Recall command button 
    With olInsp 
     .Display 
     .CommandBars.FindControl(, 2511).Execute 
     .Close olDiscard 
    End With 

최종면 최종 하위

감가 상각 및 IRibbonExtensibility 함께 ///// 내 코드는 다음과 같습니다.

Outlook.MailItem MailItemRecall = (MailItem)selObject; 
    if (MailItemRecall != null) 
      { 


       Outlook.Action recallaction = selObject.Actions.Add(); 
       recallaction.Name = "Recall This Message"; 
       recallaction.MessageClass = "IPM.Outlook.Recall"; 
       recallaction.ResponseStyle = OlActionResponseStyle.olSend; 
       recallaction.CopyLike = OlActionCopyLike.olReplyFolder; 
       recallaction.Execute(); 
}