How to Auto Count the Attendees before Sending a Meeting Invitation in Your Outlook

This article will teach you how to utilize Outlook VBA to automatically get a count of attendees before sending out a meeting invitation. 

Similar to count the recipients before sending out an email, some users also wish to count the attendees before sending a meeting invitation. As usual, this aims to estimate the total cost of the proposed meeting and then decide if to send such a meeting invitation to the attendees. Moreover, since Outlook permits users to set attendees as required or optional, some would like to count attendees in different types. And it couldn’t be better if meeting resources and duration can be included. Though Outlook has no such a direct feature, you still can make use of VBA code to realize it.

Auto Count the Attendees before Sending a Meeting Invitation in Your Outlook

Auto Count the Attendees before Sending a Meeting Invitation

  1. To start with, launch your Outlook program.
  2. Then in main Outlook window, press “Alt + F11” key shortcuts.
  3. Next you will enter Outlook VBA editor successfully. Now you need find and open “ThisOutlookSession” project.
  4. Subsequently, copy and paste the following VBA codes into this project.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim objMeetingInvitation As Outlook.MeetingItem
    Dim objMeeting As Outlook.AppointmentItem
    Dim objAttendees As Outlook.Recipients
    Dim objAttendee As Outlook.recipient
    Dim lRequiredAttendeeCount, lOptionalAttendeeCount, lResourceCount As Long
    Dim strMsg As String
    Dim nPrompt As Integer
 
    If TypeOf Item Is MeetingItem Then
       Set objMeetingInvitation = Item
       Set objMeeting = objMeetingInvitation.GetAssociatedAppointment(True)
       Set objAttendees = objMeetingInvitation.Recipients
    End If
 
    lRequiredAttendeeCount = 0
    lOptionalAttendeeCount = 0
    lResourceCount = 0
 
    'Count the required & optional attendees and resources, etc.
    For Each objAttendee In objAttendees
         If objAttendee.Type = olRequired Then
            lRequiredAttendeeCount = lRequiredAttendeeCount + 1
         ElseIf objAttendee.Type = olOptional Then
            lOptionalAttendeeCount = lOptionalAttendeeCount + 1
         ElseIf objAttendee.Type = olResource Then
            lResourceCount = lResourceCount + 1
         End If
    Next
 
    'Double check the meeting invitation details
    strMsg = "Meeting Details:" & vbCrLf & vbCrLf & _
     "Required Attendees: " & lRequiredAttendeeCount & vbCrLf & _
     "Optional Attendees: " & lOptionalAttendeeCount & vbCrLf & _
     "Resources: " & lResourceCount & vbCrLf & _
     "Duration: " & GetDuration(objMeeting) & vbCrLf & vbCrLf & _
     "Are you sure to send this meeting invitation?"
 
    nPrompt = MsgBox(strMsg, vbExclamation + vbYesNo, "Double Check Meeting Invitation")
 
    If nPrompt = vbYes Then
       Cancel = False
    Else
       Cancel = True
    End If
End Sub

Function GetDuration(objCurMeeting As AppointmentItem) As String
    'Convert minute to hour
    If objCurMeeting.Duration > 60 Then
       GetDuration = Round(objCurMeeting.Duration / 60, 1) & " hours"
    ElseIf objCurMeeting.Duration = 60 Then
       GetDuration = Round(objCurMeeting.Duration / 60, 1) & " hour"
    ElseIf objCurMeeting.Duration < 60 Then
       GetDuration = objCurMeeting.Duration & " mins"
    End If
End Function

VBA Code - Auto Count the Attendees before Sending a Meeting Invitation

  1. After that, you need to sign this code.
  2. Later make sure your Outlook permits the digitally signed macros.
  3. From now on, every time you click the “Send” button in meeting invitations, you’ll get a message showing the count of attendees, resources and duration, like the following image:Message showing the count of attendees

Cope with Frustrating Outlook Corruption Flexibly

Perhaps you’ve ever encountered Outlook issues before, such as freezing, various error messages and so on. Fortunately, Outlook comes preinstalled with an inbox repair tool, called as Scanpst, which is capable of solving small issues. But if the problem is serious, you will be required to recur to a more specialized tool, such as DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt mdf and outlook repair software products. For more information visit www.datanumen.com

One response to “How to Auto Count the Attendees before Sending a Meeting Invitation in Your Outlook”

Leave a Reply

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