我希望能够过滤发送给超过 15 人的电子邮件?在 Outlook 2016 中可以实现吗?或者是否可以使用带有开发人员选项的宏/Visual Basic 来创建类似的东西?
由于我要求进行过滤,因此这个问题并不是重复的,而不是当我意外地向 +15 个人发送电子邮件时发出的警告。
答案1
Public WithEvents myOlApp As Outlook.Application
Sub Application_Startup()
Set myOlApp = Outlook.Application
End Sub
Private Sub myOlApp_NewMailEx(ByVal EntryIDCollection As String)
Dim item As MailItem
Dim olItem As Outlook.MailItem
Dim arr() As String
Dim i As Integer
Dim objFolderInbox As Outlook.MAPIFolder
Dim objFolderDL As Outlook.MAPIFolder
Set objNS = myOlApp.GetNamespace("MAPI")
Set objFolderInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolderDL = objFolderInbox.Folders("E-mail DL")
On Error GoTo ErrorHandler
' Split collection
arr = Split(EntryIDCollection, ",")
' For each new e-mail / event / etc
For i = 0 To UBound(arr)
' Set item
Set item = objNS.GetItemFromID(arr(i))
' Check if e-mail
If item.Class = olMail Then
Set olItem = item
Set Recips = olItem.Recipients
' Check if number of recipients > 15
If Recips.Count > 15 Then
' Move to different folder
olItem.Move objFolderDL
End If
End If
Next
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub