Outlook
A family of Microsoft email and calendar products.
4,492 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
Could you please teach me how to run (execute) VBA when mail (item) is added in sent mail box of Outlook?
About Outlook VBA (Visual Basic for Applications).
By running below code, the code sometimes can't be runned.
(VBE Project1(VBAProject.OTM) Microsoft Outlook Objects ThisOutlookSession)
Option ExplictDim WithEvents mySentItems As Items
Private Sub Application_ItemLoad(ByVal Item As Object)
End Sub
Private Sub Application_Startup()
Set mySentItems = Session.GetDefaultFolder(olFolderSentMail).Items
End Sub
Private Sub mySentItems_ItemAdd(ByVal Item As Object)
' code I would like to execute
End Sub
condition:
Windows10 Pro 21H2(OS build 19044.2486)
Outlook : subscription Microsoft 365 Apps for enterprise
- All macros are enabled.
- I restarted Outlook.
- I runned quick repair of Office.
Thank you very much for your cooperation with the matters mentioned above.
Hi ChristyZhang,
I am grateful for your support !
Thank you very much for your cooperation.
Kind regards.