How to Batch Send a Calendar to Multiple Contacts in Separate Emails via Outlook VBA

If you want to send calendar attached as iCalendar file to multiple contacts in separate emails, generally, you have to send one by one. But, it is too tedious. Thus, in this article, we will teach you a more effective way that can let you get it in bulk.

In Calendar page, you can find the “Email Calendar” button in “Share” group on “Home” tab. After you click it, a new email will display. Now, you can send the calendar to others via this email. You can add multiple contacts in the “To” field. But, sometimes, you may want to send a calendar to multiple contacts in separate emails. In this situation, you can use the following way to realize it in batch.

Email Calendar

Batch Send a Calendar to Multiple Contacts in Separate Emails

  1. First, press “Alt + F11” to access VBA editor.
  2. Then, copy the following VBA code into a blank module.
Sub EmailCalendarToMultiplePersonsSeparately()
    Dim objSelection As Outlook.Selection
    Dim objCalendarFolder As Outlook.Folder
    Dim objCalendarExporter As Outlook.CalendarSharing
    Dim dStartDate, dEndDate As Date
    Dim striCalendarFile As String
    Dim objContact As Outlook.ContactItem
    Dim objMail As Outlook.MailItem

    Set objSelection = Outlook.Application.ActiveExplorer.Selection
 
    If Not objSelection Is Nothing Then
       Set objCalendarFolder = Outlook.Application.Session.PickFolder
 
       If Not objCalendarFolder Is Nothing Then
          If objCalendarFolder.DefaultItemType = olAppointmentItem Then
             Set objCalendarExporter = objCalendarFolder.GetCalendarExporter
 
             dStartDate = InputBox("Enter the start date", "Start Date", "1/1/2018")
             dEndDate = InputBox("Enter the end date", "End Date", "2/27/2018")
 
             If dStartDate <> #1/1/4501# And dEndDate <> #1/1/4501# Then
                striCalendarFile = "E:\" & "Calendar (" & Format(dStartDate, "YYYYMMDD") & " - " & Format(dEndDate, "YYYYMMDD") & ").ics"
 
                With objCalendarExporter
                    .IncludeWholeCalendar = False
                    .startDate = dStartDate
                    .EndDate = dEndDate
                    .CalendarDetail = olFullDetails
                    .IncludeAttachments = True
                    .IncludePrivateDetails = False
                    .RestrictToWorkingHours = False
                    .SaveAsICal striCalendarFile
               End With
 
               For Each objContact In objSelection
                   Set objMail = Outlook.Application.CreateItem(olMailItem)
                   With objMail
                       .To = objContact.Email1Address
                       .Recipients.ResolveAll
                       .Subject = "Calendar [" & Format(dStartDate, "YYYYMMDD") & "~" & Format(dEndDate, "YYYYMMDD") & "]"
                       .Attachments.Add striCalendarFile
                       .Body = "Dear " & objContact.FullName & "," & vbCrLf & "Type body here..."
                       .Display
                       '.Send
                   End With
               Next
             End If
          End If
       End If
    End If
End Sub

VBA Code - Batch Send a Calendar to Multiple Contacts in Separate Emails

  1. After that, close the VBA editor.
  2. Subsequently, add this macro to Quick Access Toolbar (QAT) with reference to “How to Run VBA Code in Your Outlook“.
  3. Finally, follow these steps to have a try.
  • First off, open a contacts folder and select the contacts which you want.
  • Then, click the macro button in QAT.Run Macro on Selected Contacts
  • Next, select the calendar that you want in popup dialog box.Select Calendar
  • After that, enter a date range of the calendar to be exported.Enter Date Range
  • After that, separate emails to be sent to the selected contacts will display, like the following figure.Separated Emails with Attached Calendar

Get Back Precious Outlook Data

In the event of Outlook data corruption, what would you do then? Generally, if you hold an updated backup, you can easily recover Outlook data from backup. If not, you have no alternative but to take aid of a top-ranking and experienced Outlook fix tool, such as DataNumen Outlook Repair. It can get back maximum Outlook data regardless of how extremely your Outlook file is damaged.

Author Introduction:

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

Leave a Reply

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