防止在 Outlook 收件箱的一个特定子文件夹中删除电子邮件
Prevent emails from being deleted in one specific child folder of the Outlook inbox
我正在尝试了解如何限制 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;
}
替换行
fldr = (Outlook.Folder)this.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
和
fldr = (Outlook.Folder)this.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox).Folders["ReadMail"];
我正在尝试了解如何限制 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;
}
替换行
fldr = (Outlook.Folder)this.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
和
fldr = (Outlook.Folder)this.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox).Folders["ReadMail"];