none
debuging the code RRS feed

  • Question

  • Hi again,

    I have a problem with debuging my vba code in outlook

    when I  write this:

    Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    
    End Sub

    it shows Macros window, that is empty,  when I press run key.

    but I dont have this problem when i write this:

    Private Sub Application_NewMailEx()
    
    End Sub

     whats the problem and what should I do?

    Thank you all

    Tuesday, August 12, 2014 7:08 AM

Answers

  • Hello Samira,

    The following method is an event handler for the NewMailEx event of the Application class:

    Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    
    End Sub

    You can't it run directly via Run Sub (F5). It is run by Outlook automatically.

    Wednesday, August 13, 2014 7:18 AM
  • Hi,

    >>but it doesnt work when I receive an email!<<

    Expanding Eugene's reply, to run the function automatically when receiving an Email, you need to make sure that the function is in the Microsoft Outlook Objects -> ThisOutlookSession instead of in a Module.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 14, 2014 2:39 AM
    Moderator
  • Where is your code now, and what does it look like?

    The Macros list will not show anything that takes arguments, only Public Subs with no arguments. It will never show event handlers such as NewMailEx().

    When a new email is delivered to Outlook you should get the event - if it's in ThisOutlookSession, Outlook is set to allow VBA code to run, and the event signature is correct. The easiest way to have the correct signature is as shown in Luna's post you select Application in the left-hand code window dropdown and NewMailEx in the right-hand dropdown.


    Ken Slovak MVP - Outlook

    Thursday, August 14, 2014 9:25 PM
    Moderator

All replies

  • Hi,

    I'm moving this thread to Outlook for Developers so that you can get more specific support on this problem.

    Regards,

    Melon Chen
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs.
    Wednesday, August 13, 2014 2:59 AM
  • Hello Samira,

    The following method is an event handler for the NewMailEx event of the Application class:

    Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    
    End Sub

    You can't it run directly via Run Sub (F5). It is run by Outlook automatically.

    Wednesday, August 13, 2014 7:18 AM
  • ok 

    but it doesnt work when I receive an email!

    I tried to add it to the rules and alerts but It dose n't shown in scripts list!

    Wednesday, August 13, 2014 12:02 PM
  • If VBA code is not running on the machine you need to check the VBA and security settings in Outlook.  

    Also please see  Outlook.ApplicationEvents_11_NewMailExEventHandler(Application_NewMailEx) not working .

    Wednesday, August 13, 2014 12:25 PM
  • Hi,

    >>but it doesnt work when I receive an email!<<

    Expanding Eugene's reply, to run the function automatically when receiving an Email, you need to make sure that the function is in the Microsoft Outlook Objects -> ThisOutlookSession instead of in a Module.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 14, 2014 2:39 AM
    Moderator
  • unfortunately non of these posts helped me!!!! :(
    Thursday, August 14, 2014 7:22 AM
  • Did you try to a add a message box to the NewMailEx event handler?

    Do you see a message box when a new message is arrived into the mailbox?

    Thursday, August 14, 2014 8:52 AM
  • Where is your code now, and what does it look like?

    The Macros list will not show anything that takes arguments, only Public Subs with no arguments. It will never show event handlers such as NewMailEx().

    When a new email is delivered to Outlook you should get the event - if it's in ThisOutlookSession, Outlook is set to allow VBA code to run, and the event signature is correct. The easiest way to have the correct signature is as shown in Luna's post you select Application in the left-hand code window dropdown and NewMailEx in the right-hand dropdown.


    Ken Slovak MVP - Outlook

    Thursday, August 14, 2014 9:25 PM
    Moderator
  •  it works!

    thank you all

    Saturday, August 16, 2014 4:51 AM