How to forward a selected appointment as private with a shortcut?

MW-0224 0 Reputation points
2024-10-16T10:23:03.4533333+00:00

I want to have an easy shortcut, e.g. a VBA macro, that forwards a selected appointment in the Outlook calendar to a specified mail address, such that the receiver also gets appointment updates automatically. The subject and body should not be changed. But the forwarded item should have "private" sensitivity.

I tried to implement it with VBA but failed. An AppointmentItem does not provide a Forward method. A MeetingItem cannot be created directly.

But when I click forward in the GUI, a MeetingItem is created and opened that can be sent. How can I at least emulate this behaviour?

Outlook
Outlook
A family of Microsoft email and calendar products.
4,382 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Joan Hua-MSFT 4,040 Reputation points Microsoft Vendor
    2024-10-17T07:18:49.2366667+00:00

    Hi @MW-0224

    Welcome to our forum!

    Please kindly understand that the Outlook tag here we mainly focus on general issues about Outlook desktop client. A suggestion at the individual level is to create a forwarding rule for relevant emails, such as marking messages or body text that contain the specific word "meeting" as private and forwarding it to the people you want to forward. More information: Manage email messages by using rules in Outlook - Microsoft Support 

    However, if you prefer to start with VBA, here are some relevant codes for your reference, but you may need to consult a more professional IT for details.

    1. Access the selected appointment: Get the currently selected appointment item.
    2. Create a new MeetingItem: Use the CreateItem method to create a new MeetingItem.
    3. Copy details from the AppointmentItem to the MeetingItem: Transfer the subject, body, and other relevant details.
    4. Set the sensitivity to private: Adjust the sensitivity of the MeetingItem.
    5. Send the MeetingItem: Forward the MeetingItem to the specified email address.

    Here's a sample VBA macro to get you started:

    Sub ForwardAppointmentAsMeeting()
        Dim objApp As Outlook.Application
        Dim objSelection As Outlook.Selection
        Dim objAppointment As Outlook.AppointmentItem
        Dim objMeeting As Outlook.MeetingItem
        Dim objRecipient As Outlook.Recipient
        
        ' Initialize Outlook application
        Set objApp = Application
        ' Get the selected items in the calendar
        Set objSelection = objApp.ActiveExplorer.Selection
        
        ' Check if the selected item is an appointment
        If objSelection.Count > 0 Then
            If TypeOf objSelection.Item(1) Is Outlook.AppointmentItem Then
                Set objAppointment = objSelection.Item(1)
                
                ' Create a new meeting item
                Set objMeeting = objApp.CreateItem(olMeetingRequest)
                
                ' Copy details from the appointment to the meeting item
                With objMeeting
                    .Subject = objAppointment.Subject
                    .Body = objAppointment.Body
                    .Start = objAppointment.Start
                    .End = objAppointment.End
                    .Location = objAppointment.Location
                    .Sensitivity = olPrivate ' Set sensitivity to private
                    
                    ' Add recipient
                    Set objRecipient = .Recipients.Add("recipient@example.com")
                    objRecipient.Type = olTo
                    
                    ' Send the meeting request
                    .Send
                End With
            Else
                MsgBox "Please select an appointment item.", vbExclamation
            End If
        Else
            MsgBox "No items selected.", vbExclamation
        End If
    End Sub
    

    Replace "recipient@example.com" with the email address you want to forward the appointment to. This macro will create a new meeting request with the same details as the selected appointment and send it to the specified recipient with the sensitivity set to private.

    Hope it helps! 


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  

    Note: Please follow the steps in our [documentation] to enable e-mail notifications if you want to receive the related email notification for this thread. 


  2. Joan Hua-MSFT 4,040 Reputation points Microsoft Vendor
    2024-10-18T02:25:39.2733333+00:00

    Hi @MW-0224

    Thanks for your patience.

    The above code is for the appointment you created, but you want to automatically forward it to the specified person through the code, because it does not support using CreateItem to create a MeetingItem object directly, so it is recommended that when you create an appointment, only add yourself as a participant, convert it into a meeting item, and then the code can run more smoothly.

    However, if what you want is a code that is automatically forwarded for meetings with multiple attendees, you need to improve the code. To avoid sending cancellations to the original recipients while forwarding the appointment to a specific recipient, you can create a new AppointmentItem and set it as a meeting. This way, you won't modify the original appointment, and you can control the recipients.

    Here's an updated approach:

    1. Create a new AppointmentItem.
    2. Copy details from the original appointment.
    3. Set the new appointment as a meeting.
    4. Add the specific recipient.
    5. Send the new meeting request.

    Here's the VBA code to achieve this:

    Sub ForwardAppointmentAsNewMeeting()
        Dim objApp As Outlook.Application
        Dim objSelection As Outlook.Selection
        Dim objOriginalAppointment As Outlook.AppointmentItem
        Dim objNewAppointment As Outlook.AppointmentItem
        Dim objRecipient As Outlook.Recipient
        
        ' Initialize Outlook application
        Set objApp = Application
        ' Get the selected items in the calendar
        Set objSelection = objApp.ActiveExplorer.Selection
        
        ' Check if the selected item is an appointment
        If objSelection.Count > 0 Then
            If TypeOf objSelection.Item(1) Is Outlook.AppointmentItem Then
                Set objOriginalAppointment = objSelection.Item(1)
                
                ' Create a new appointment item
                Set objNewAppointment = objApp.CreateItem(olAppointmentItem)
                
                ' Copy details from the original appointment to the new appointment
                With objNewAppointment
                    .Subject = objOriginalAppointment.Subject
                    .Body = objOriginalAppointment.Body
                    .Start = objOriginalAppointment.Start
                    .End = objOriginalAppointment.End
                    .Location = objOriginalAppointment.Location
                    .Sensitivity = olPrivate ' Set sensitivity to private
                    .MeetingStatus = olMeeting ' Set as a meeting
                    
                    ' Add recipient
                    Set objRecipient = .Recipients.Add("recipient@example.com")
                    objRecipient.Type = olTo
                    
                    ' Send the meeting request
                    .Send
                End With
            Else
                MsgBox "Please select an appointment item.", vbExclamation
            End If
        Else
            MsgBox "No items selected.", vbExclamation
        End If
    End Sub
    

    This macro creates a new appointment with the same details as the selected one, sets it as a meeting, adds the specified recipient, and sends it. This way, the original appointment remains unchanged, and no cancellations are sent to the original recipients.

    Hope it helps.


  3. Peter Jagaraj 0 Reputation points
    2025-01-30T16:27:51.7466667+00:00

    The above solution will work for what I am trying to solve, i.e., '''accept', 'tentative' or 'remove from calendar' action to trigger a VBA macro to forward the calendar item as .ics file to my personal calendar". Instead of sending as an ics file, I can use the above solution to forward the calendar items. I am kind of lost on how to trigger the VBA code on ''accept', 'tentative' or 'remove from calendar'.

    Thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.