如何仅读取 VSTO Outlook MailItem 正文中的新内容?
我为 Outlook 2003 编写了一个小型 C# VSTO 插件,它可以在发送电子邮件时读取电子邮件正文,查找某些单词。它现在正在执行以下操作:
if (currentItem.Body.Contains("text to search for"))
...但是它会检查整个电子邮件正文,而不仅仅是正在发送的新消息。
无论如何,是否可以让 Outlook 仅检查正在发送的新邮件的内容,从而忽略其中可能存在的旧电子邮件链?
这些消息可以是任何格式(HTML、富文本、纯文本),并且可能包含也可能不包含任何早期消息。这对我来说只是一个生产力工具,因此任何有效的技巧都值得在这里考虑。
谢谢!
I've written a little C# VSTO add-in for Outlook 2003 that reads the body of emails as they are being sent, looking for certain words. It's working right now to do this:
if (currentItem.Body.Contains("text to search for"))
... but that checks the entire email body, not just the new message being sent.
Is there anyway to have Outlook just check the contents of the new message being sent, and so ignore the older email chain that might be in there too?
These messages could be in any format (HTML, Rich Text, Plain Text) and may or may not have any earlier messages chained in. This is just a productivity tool for me, so any hack that works is worth considering here.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@Corbin March 在这里有最好的答案 使用 Mime 解析器分隔多部分电子邮件
@Corbin March has the best answer here Separate a multipart email using Mime Parsers
根据记录,我认为最适合我的解决方案是简单地检查以“FROM:”开头的行,Mikael 建议。一旦找到我的文字,我就停止搜索。这对我来说已经工作了一段时间了。
谢谢大家的回复和想法。
这是我的代码供参考:
For the record, the solution I decided worked best for me was to simply check for a line starting with "FROM:", Mikael suggested. I stop searching for my text as soon as that is found. That's been working just fine for me for a while now.
Thanks for the responses and ideas, everyone.
Here's my code for reference: