【发布时间】:2016-01-14 16:12:10
【问题描述】:
我试图弄清楚如何限制 Outlook 2010 中的一个文件夹删除它的邮件项。我有以下代码示例运行良好,但仅适用于收件箱文件夹(OlDefaultFolders.olFolderInbox)。我试图弄清楚如何限制一个文件夹和一个仅在收件箱下方的文件夹。例如 Inbox\ReadMail 我想阻止用户仅从 ReadMail 中删除。提前感谢您的任何帮助。
public partial class ThisAddIn
{
Microsoft.Office.Interop.Outlook.MailItem mail = null;
Outlook.Inspectors inspectors = null;
Outlook.Folder fldr = null;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
inspectors = this.Application.Inspectors;
// Is there a way to edit the folloing line to point to a certain sub folder of the inbox folder?
inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler (Inspectors_NewInspector);
fldr = (Outlook.Folder)this.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
fldr.BeforeItemMove += new Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(fldr_BeforeItemMove);
}
void fldr_BeforeItemMove(object Item, Microsoft.Office.Interop.Outlook.MAPIFolder MoveTo, ref bool Cancel)
{
MessageBox.Show("You are not permitted to delete emails from this folder");
Cancel = true;
}
【问题讨论】:
标签: c# visual-studio outlook-addin outlook-2010 outlook-redemption