【发布时间】:2022-02-23 22:09:17
【问题描述】:
下面的代码完美运行:
Option Explicit
Dim myOlApp As New Outlook.Application
Public WithEvents myOlInspectors As Outlook.Inspectors
Private Sub Application_Startup()
Initialize_handler
End Sub
Public Sub Initialize_handler()
Set myOlInspectors = myOlApp.Inspectors
End Sub
Private Sub myOlInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
Dim msg As Outlook.MailItem
If Inspector.CurrentItem.Class = olMail Then
Set msg = Inspector.CurrentItem
If msg.Size = 0 Then
'MsgBox "New message" ' TEST LINE
msg.CC = "email@email.com"
End If
End If
End Sub
但是,经过几个小时的工作。它突然停止发射(我没有收到任何错误)。
我对代码有什么误解吗?
是否有关于 Outlook.Inspectors 的问题,导致它由于某种原因停止启动?
【问题讨论】:
-
建议的解决方法。 *.com/questions/48548203/…。您可以从
Application_ItemSend运行Initialize_handler或手动运行 *.com/questions/29972061/…。