Answers:
一个 VBA
像下面这样的脚本可以完成这项工作:
Option Explicit
Sub DoubleSimonMessageRule(newMail As Outlook.mailItem)
Dim a() As String ' we convert the mail body to an array of string
Dim EntryID As String
Dim StoreID As Variant
Dim mi As Outlook.mailItem
Dim dest As String
Dim destFldr As Outlook.Folder
Dim I As Integer
Dim iMatch As Integer
Const pattern = "Simon"
Const dest1 = "Simon1" ' destination folder for 1 match
Const destAny = "SimonAny" ' destination folder for 2+ matches
On Error GoTo ErrHandler
' we have to access the new mail via an application reference
' to avoid security warnings
EntryID = newMail.EntryID
StoreID = newMail.Parent.StoreID
Set mi = Application.Session.GetItemFromID(EntryID, StoreID)
a = Split(mi.body, vbCrLf)
iMatch = 0
For I = LCase(a) To UCase(a)
If InStr(1, a(I), pattern, vbTextCompare) Then
iMatch = iMatch + 1
End If
Next I
If iMatch < 1 Then
' this should not happen, provided our rule is configured properly
Err.Raise 1, , "No " & pattern & " in Mail"
ElseIf iMatch = 1 Then
dest = dest1
ElseIf iMatch > 1 Then
dest = destAny
End If
Set destFldr = Application.GetNamespace("MAPI").Folders(dest)
mi.Move destFldr
' mi.Delete ' not sure about this!
Set mi = Nothing
Exit Sub
ErrHandler:
Debug.Print Err.Description
Err.Clear
On Error GoTo 0
End Sub
使用Outlook Rule Assistant为其邮件正文中包含“Simon”的传入邮件调用此脚本。