Debug Outlook Web Add-ins with Visual Studio

Updated:

Note

This article describes a historical procedure based on the Outlook and Internet Explorer configuration in March 2019. Current debugging methods for Office Add-ins vary by development environment and Outlook client. For current guidance, see the Microsoft Learn overview of debugging Office Add-ins.

日本語版は Outlook Web アドインを Visual Studio でデバッグする方法 から確認できます。

To debug an Outlook Web Add-in (an add-in for the Outlook desktop client that uses the JavaScript API for Office) with Visual Studio, change the settings for Internet Explorer, which Outlook uses internally, so that a debugger such as Visual Studio starts when you want to debug. The exact steps may vary slightly depending on your test environment, but the following procedure provides an example.

Debug Outlook Web Add-ins with Visual Studio

  1. In Internet Explorer on the computer where you will debug, open the Advanced tab in Internet Options and clear these two check boxes:

    • Disable script debugging (Internet Explorer)
    • Disable script debugging (Other)
  2. Open the JavaScript file in Visual Studio and add debugger; on the line where you want to break. For example:

    1
    2
    3
    4
    5
    6
    // Format an EmailAddressDetails object as
    // GivenName Surname <emailaddress>
    function buildEmailAddressString(address) {
    debugger;
    return address.displayName + " <" + address.emailAddress + ">";
    }
  3. Deploy the add-in and install it in a test mailbox so that it is available in that mailbox.

  4. Start Outlook on the computer where you will debug, and perform the actions that execute the line containing debugger;.

  5. If a dialog appears for selecting a debugger, select the debugger you want to use and click OK.

    Dialog for selecting a debugger to use with an Outlook Web Add-in
  6. The selected debugger (such as Visual Studio) starts attached to iexplorer.exe and breaks on the debugger; line. You can now debug the add-in.

  7. When you finish, close Outlook. The debugger detaches from iexplorer.exe, so close the debugger as well. If it does not detach automatically, detach it manually before closing it. If you are prompted to save the solution file, you can select No.

Advertisement