如何判断一封邮件是新发、回复还是转发?
我使用 Visual Studio 2010 创建 Outlook 2007 插件。现在我想知道一封电子邮件是新发送的、回复的还是转发的。有这个属性吗?
using Outlook = Microsoft.Office.Interop.Outlook;
namespace _Outlook2k7_Add_In
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
void Application_ItemSend(object Item, ref bool Cancel)
{
Outlook.MailItem mail = Item as Outlook.MailItem;
if (mail == null)
return;
// Magic?
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
this.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
}
#endregion
}
}
I use Visual Studio 2010 to create an Outlook 2007 Addin. Now i want to know whether a e-mail was newly sent, replied or forwarded. Is there any property for this?
using Outlook = Microsoft.Office.Interop.Outlook;
namespace _Outlook2k7_Add_In
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
void Application_ItemSend(object Item, ref bool Cancel)
{
Outlook.MailItem mail = Item as Outlook.MailItem;
if (mail == null)
return;
// Magic?
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
this.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
}
#endregion
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有 3 个扩展 MAPI 属性用于处理回复/转发的邮件状态:
PR_ICON_INDEX (0x10800003)
PR_LAST_VERB_EXECUTED (0x10810003)
PR_LAST_VERB_EXECUTION_TIME (0x10820040)
要在 Outlook 2007/2010 中获取这些值,请使用 PropertyAccessor 对象:
http://msdn.microsoft.com/en-us/library/bb176395(office.12).aspx
如果正在发送,MailItem.Sent 属性仍将为 False。
There are 3 Extended MAPI properties that deal with the message state for replied to/forwarded:
PR_ICON_INDEX (0x10800003)
PR_LAST_VERB_EXECUTED (0x10810003)
PR_LAST_VERB_EXECUTION_TIME (0x10820040)
To get these values in Outlook 2007/2010, use the PropertyAccessor Object:
http://msdn.microsoft.com/en-us/library/bb176395(office.12).aspx
If it's a send in progress, the MailItem.Sent property will still be False.
这似乎对我来说非常有效。我不知道邮件项目本身会有这些信息。您可以改为过滤 olFolderSentMail 文件夹。
This seems to work really well for me. I don't know that the mailitem itself would have this information. You could filter the olFolderSentMail folder instead.