简体   繁体   English

如何在Outlook插件中排除原始邮件

[英]How to exclude original messages in Outlook plugin

I am writing an Outlook 2010/2013 plugin with C#. 我正在使用C#编写Outlook 2010/2013插件。 My abridged code looks like this: 我的节略代码如下:

using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
public partial class ThisAddIn
{
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {            
        Application.ItemSend += Application_ItemSend;
    }

    void Application_ItemSend(object Item, ref bool Cancel)
    {
        Outlook.MailItem mailItem = Item as Outlook.MailItem;
        // Scan for keywords before the user sends the email.
    }
}

When the user hits the Send button on an email, the Application_ItemSend event handler executes. 当用户单击电子邮件上的“发送”按钮时,将执行Application_ItemSend事件处理程序。 At that point, I want to scan the message body for certain keywords. 那时,我想在邮件正文中扫描某些关键字。 However, I want to exclude older/original messages in that scan. 但是,我想在该扫描中排除较旧/原始的邮件。 I only want to scan the message that the user has just typed... mailItem.Body and mailItem.HTMLBody contain not only the message that the user is sending, but they also include all the previous messages in the entire thread/conversation. 我只想扫描用户刚刚键入的消息... mailItem.BodymailItem.HTMLBody不仅包含用户正在发送的消息,而且还包含整个线程/会话中的所有先前消息。 How can I filter those out? 我该如何过滤掉它们?

I've not tested this myself yet, but this is on my todo list for our Addin as well. 我自己尚未对此进行测试,但这也在我的Addin的待办事项列表中。 I haven't been able to find much documentation on this, but the OOXML of the mail (as well as the HTML) - at least in 2013 - contain something like the following: 我还没有找到很多关于此的文档,但是邮件的OOXML(以及HTML)(至少在2013年)包含以下内容:

OOXML: OOXML:

<w:bookmarkStart w:id="0" w:name="_MailOriginal"/>

HTML: HTML:

<span style='mso-bookmark:_MailOriginal'>

This bookmark should allow you to find the point where you can cut off the message - as far as I know there is no other option in the API. 就我所知,API中没有其他选项,因此该书签应该可以让您找到可以截断消息的地方。

See here on how to get the OOXML of the mail: 请参阅此处,了解如何获取邮件的OOXML:

Word.Document document = mailItem.GetInspector.WordEditor;
string xml = document.WordOpenXML;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM