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.
Microsoft 365 and Office | Development | Other
Outlook | Windows | Classic Outlook for Windows | For business
{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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.