How can I programmatically cancel an outlook meeting with asp net vb


Canceling an Outlook meeting programmatically using ASP.NET VB can be achieved by leveraging the Microsoft Graph API. The Microsoft Graph API provides a powerful set of tools and for interacting with Outlook data, including the ability to cancel meetings. In this article, we will explore how to programmatically cancel an Outlook meeting using ASP.NET VB with the help of the Microsoft Graph API.


Before we dive into the code, there are a few prerequisites that need to be met:

  • An active Microsoft 365 subscription with Outlook .
  • An AD application registered in the Azure portal with the necessary permissions to access the Microsoft Graph API.
  • Basic knowledge of ASP.NET VB and the Microsoft Graph API.

Step 1: Set up Azure AD Application

The first step is to set up an Azure AD application in the Azure portal. This application will act as the for our ASP.NET VB application to access the Microsoft Graph API. Follow these steps to set up the Azure AD application:

  1. Go to the Azure portal ( and sign in with your Microsoft 365 account.
  2. Navigate to the Azure Active Directory section.
  3. Click on “App registrations” and then “New registration”.
  4. Provide a name for your application and select the appropriate account type.
  5. Under “Redirect URI”, select “Web” and the URL of your ASP.NET VB application.
  6. Click on “” to create the application.
  7. Note down the “Application () ID” and “Directory (tenant) ID” as we will need them later.

Step 2: Grant API Permissions

Next, we need to grant the necessary API permissions to our Azure AD application. Follow these steps to grant the required permissions:

  1. Go to the Azure portal and navigate to the Azure Active Directory section.
  2. Click on “App registrations” and select your application.
  3. Under “Manage”, click on “API permissions”.
  4. Click on “Add a permission” and select “Microsoft Graph”.
  5. Choose the appropriate permission(s) required to cancel meetings, such as “Calendars.ReadWrite” and “Calendars.ReadWrite.”.
  6. Click on “Add permissions” to grant the selected permissions.

Step 3: Implementing the Code

Now that we have set up the Azure AD application and granted the necessary permissions, let's dive into the code. Below is an example of how to programmatically cancel an Outlook meeting using ASP.NET VB:

Imports Microsoft.Graph
Imports Microsoft.Identity.Client

Public Class CancelMeeting
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim clientId As String = "YOUR_CLIENT_ID"
        Dim clientSecret As String = "YOUR_CLIENT_SECRET"
        Dim tenantId As String = "YOUR_TENANT_ID"

        Dim graphClient As GraphServiceClient = GetGraphClient(clientId, clientSecret, tenantId)

        Dim meetingId As String = "MEETING_ID_TO_CANCEL"

            Response.Write("Meeting canceled successfully!")
        Catch ex As Exception
            Response.Write("Failed to cancel the meeting: " & ex.Message)
        End Try
    End Sub

    Private Function GetGraphClient(ByVal clientId As String, ByVal clientSecret As String, ByVal tenantId As String) As GraphServiceClient
        Dim clientApplication As ConfidentialClientApplication = New ConfidentialClientApplication(clientId, $"{tenantId}/v2.0", $"", New ClientCredential(clientSecret), Nothing, Nothing)
        Dim authenticationResult As AuthenticationResult = clientApplication.AcquireTokenForClient(New String() {""}).Result
        Return New GraphServiceClient(New DelegateAuthenticationProvider(Function(requestMessage)
                                                                           requestMessage.Headers.Authorization = New System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken)
                                                                           Return Task.FromResult(0)
                                                                       End Function))
    End Function
End Class

In the above code, make sure to replace the placeholders “YOUR_CLIENT_ID”, “YOUR_CLIENT_SECRET”, “YOUR_TENANT_ID”, and “MEETING_ID_TO_CANCEL” with the values from your Azure AD application and the meeting you want to cancel.


By leveraging the Microsoft Graph API and the power of ASP.NET VB, we can programmatically cancel Outlook meetings. In this article, we discussed the steps to set up an Azure AD application, grant API permissions, and provided an example of how to cancel a meeting using ASP.NET VB. With this knowledge, you can now Outlook meeting cancellation functionality into your ASP.NET VB applications.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents