Consulting

Results 1 to 2 of 2

Thread: trigger code when currently open email is sent

  1. #1
    VBAX Newbie
    Joined
    Oct 2007
    Posts
    2
    Location

    trigger code when currently open email is sent

    I have a VBA macro that runs in outlook and performs a few manipulations on the currently open email message. How can I trigger some additional code that will be run when the user subsequently sends (or closes) that specific message ?

    I'm not sure if Application_ItemSend would work, since I don't know the identity of the specific item in advance -- the code should not run when *any* email is sent, it should only run when the currently open email is sent (or closed)

    Thanks

  2. #2
    you can set an item (or collection of items) with events
    this must be at the top of an object module (either thisoutlooksession or a class module)
    Public WithEvents xitm As MailItem
    from some button or other code performed in the open message
    Set xitem = ActiveInspector.CurrentItem
    you can then put code in any of the events of xitm
    probably best to set xitm to nothing when the code is finished, to prevent other events from firing later

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •