-2
我想在使用c#的Outlook中構建調用消息的代碼。我在Outlook中有一個自定義選項卡並有按鈕。我需要點擊按鈕(選擇發送郵件後)創建一個代碼,它必須調用Outlook的召回消息功能。展望回顧消息c#
我知道召回消息的限制。但是組織仍想繼續這一點。 讓我們知道是否有人有C#代碼來呼叫召回消息按鈕。 感謝和問候,
我想在使用c#的Outlook中構建調用消息的代碼。我在Outlook中有一個自定義選項卡並有按鈕。我需要點擊按鈕(選擇發送郵件後)創建一個代碼,它必須調用Outlook的召回消息功能。展望回顧消息c#
我知道召回消息的限制。但是組織仍想繼續這一點。 讓我們知道是否有人有C#代碼來呼叫召回消息按鈕。 感謝和問候,
我自己找到了答案。
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: }
我怎麼編譯下面的代碼在C#2010觀爲命令欄是貶值,與IRibbonExtensibility
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
結束如果結束小組
/////我代碼看起來如下
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();
}