How to run (execute) VBA when mail (item) is added in sent mail box

Tarou99 Suzuki 0 Reputation points
2023-02-06T08:07:31.5333333+00:00
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.
Outlook
Outlook
A family of Microsoft email and calendar products.
3,319 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,680 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tarou99 Suzuki 0 Reputation points
    2023-02-08T12:47:21.4466667+00:00

    Hi ChristyZhang,

    I am grateful for your support !

    Thank you very much for your cooperation.

    Kind regards.

    0 comments No comments