gpt4 book ai didi

vba - Outlook Application_NewMailEx 在启动时不工作

转载 作者:行者123 更新时间:2023-12-01 10:32:25 26 4
gpt4 key购买 nike

我正在使用 Application_NewMailEx 来处理收到的所有电子邮件。它适用于在 Outlook 打开时收到的电子邮件。

但是在启动时,Application_NewMailEx 不会被收到的电子邮件调用。

我尝试使用 Application_Startup 但它在收到电子邮件之前被调用 ==> 不起作用。没有application.ontime延迟启动宏...Application_NewMail 做同样的事情。

如何实现?

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
INIT_FOLD
TreatMsg Application.GetNamespace("MAPI").GetItemFromID(EntryIDCollection)
End Sub

最佳答案

这是一个示例,说明当 MailItem 添加到收件箱时如何设置应用程序启动并触发您的 vba

Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olNs As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder

Set olNs = Application.GetNamespace("MAPI")
Set Inbox = olNs.GetDefaultFolder(olFolderInbox)
Set Items = Inbox.Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
Example Item ' call sub
End If
End Sub

Public Sub Example(ByVal Item As Object)
Debug.Print Item.Subject ' Immediate Window
End Sub

Application.Startup Event (Outlook) Items.ItemAdd Event (Outlook)

Items.ItemAdd Event (Outlook) Occurs when one or more items are added to the specified collection. This event does not run when a large number of items are added to the folder at once. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).


Application.Startup Event (Outlook) Occurs when Microsoft Outlook is starting, but after all add-in programs have been loaded.


关于vba - Outlook Application_NewMailEx 在启动时不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41281091/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com