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:
我为Outlook 2003写了一个c# VSTO外接程序,在邮件发送时读取邮件正文,查找特定的词汇。它正在努力做到这一点:
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?
不管怎样,Outlook只是检查发送的新消息的内容,所以忽略可能存在的旧邮件链吗?
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.
这些消息可以是任何格式(HTML、富文本、纯文本),也可以或不可以链接任何早期的消息。这对我来说只是一个生产力工具,所以任何有用的技巧都值得在这里考虑。
Thanks!
谢谢!
2 个解决方案
#1
1
@Corbin March has the best answer here Separate a multipart email using Mime Parsers
@Corbin March在这里给出了最好的答案:使用Mime解析器分离多部分电子邮件
#2
1
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.
据我所知,我认为对我来说最有效的解决方案是简单地检查以“FROM:”开头的行,Mikael建议。一旦找到我的文本,我就停止搜索。这对我来说已经有一段时间了。
Thanks for the responses and ideas, everyone.
谢谢大家的回复和想法。
Here's my code for reference:
以下是我的代码供参考:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim theLine As String
Dim aBody()
Dim bFound As Boolean
Dim ctr As Long
aBody = Array(Split(Item.Body, vbNewLine))
bFound = False
For ctr = 0 To UBound(aBody(1))
theLine = aBody(1)(ctr)
If InStr(theLine, "From:") > 0 Then
Exit For
End If
If InStr(UCase(theLine), "ATTACH") > 0 Then
bFound = True
End If
Next
If bFound Then
If Item.Attachments.Count < 1 Then
Dim ans As Integer
ans = MsgBox("Do you really want to send this without any attachments?", vbYesNo)
If ans = 7 Then
Cancel = True
Exit Sub
End If
End If
End If
End Sub
#1
1
@Corbin March has the best answer here Separate a multipart email using Mime Parsers
@Corbin March在这里给出了最好的答案:使用Mime解析器分离多部分电子邮件
#2
1
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.
据我所知,我认为对我来说最有效的解决方案是简单地检查以“FROM:”开头的行,Mikael建议。一旦找到我的文本,我就停止搜索。这对我来说已经有一段时间了。
Thanks for the responses and ideas, everyone.
谢谢大家的回复和想法。
Here's my code for reference:
以下是我的代码供参考:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim theLine As String
Dim aBody()
Dim bFound As Boolean
Dim ctr As Long
aBody = Array(Split(Item.Body, vbNewLine))
bFound = False
For ctr = 0 To UBound(aBody(1))
theLine = aBody(1)(ctr)
If InStr(theLine, "From:") > 0 Then
Exit For
End If
If InStr(UCase(theLine), "ATTACH") > 0 Then
bFound = True
End If
Next
If bFound Then
If Item.Attachments.Count < 1 Then
Dim ans As Integer
ans = MsgBox("Do you really want to send this without any attachments?", vbYesNo)
If ans = 7 Then
Cancel = True
Exit Sub
End If
End If
End If
End Sub