outlook 召回消息 c#
outlook Recall message c#
我正在尝试使用 C# 构建用于在 Outlook 中召回消息的代码。我在 outlook 中有一个自定义选项卡并有按钮。我需要在点击按钮时构建一个代码(选择已发送邮件后),它必须调用 outlook 的召回邮件功能。
我知道撤回消息的限制。但是组织仍然希望继续这样做。
如果有人有调用召回消息按钮的 c# 代码,请告诉我们。
感谢和问候,
如何在 c# 中为 outlook 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();
}
我自己找到了答案。
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# 构建用于在 Outlook 中召回消息的代码。我在 outlook 中有一个自定义选项卡并有按钮。我需要在点击按钮时构建一个代码(选择已发送邮件后),它必须调用 outlook 的召回邮件功能。
我知道撤回消息的限制。但是组织仍然希望继续这样做。 如果有人有调用召回消息按钮的 c# 代码,请告诉我们。 感谢和问候,
如何在 c# 中为 outlook 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();
}
我自己找到了答案。
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: }