How can I send Outlook (Microsoft 365) meeting invitations from one email account to multiple email accounts using PowerShell?

Jairo Javier Baleta Cali 286 Reputation points
2024-01-18T21:19:08.5933333+00:00

I need your help to create a PowerShell script to send invitations to an Outlook (Microsoft 365) meeting from an email account user@domino to multiple email accounts (user1@domino, user2@domino...) through from PowerShell I hope you can help me.

Outlook | Windows | Classic Outlook for Windows | For business
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Khaled Elsayed Mohamed 1,335 Reputation points
    2024-07-07T06:44:40.2266667+00:00

    Hi JJ try this:

    # Load the Outlook COM object
    Add-Type -AssemblyName "Microsoft.Office.Interop.Outlook"
    $outlook = New-Object -ComObject Outlook.Application
    $namespace = $outlook.GetNamespace("MAPI")
    
    # Get the account to send from
    $account = $namespace.Accounts | Where-Object {$_.SmtpAddress -eq "user@domino"}
    
    # Create a new appointment item
    $appointment = $outlook.CreateItem(1) # 1 = olAppointmentItem
    
    # Set the appointment properties
    $appointment.Subject = "Meeting Subject"
    $appointment.Body = "Meeting description goes here."
    $appointment.Location = "Meeting Location"
    $appointment.Start = (Get-Date).AddDays(1).AddHours(9) # Tomorrow at 9 AM
    $appointment.Duration = 60 # Duration in minutes
    
    # Add recipients
    $recipients = @("user1@domino", "user2@domino", "user3@domino")
    foreach ($recipient in $recipients) {
        $appointment.Recipients.Add($recipient)
    }
    
    # Set the sending account
    $appointment.SendUsingAccount = $account
    
    # Send the meeting invitation
    $appointment.Send()
    
    # Clean up
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($outlook) | Out-Null
    [System.GC]::Collect()
    [System.GC]::WaitForPendingFinalizers()
    

    This script does the following:

    • Loads the Outlook COM object.
    • Finds the specified sending account (user@domino).
    • Creates a new appointment item.
    • Sets the appointment properties (subject, body, location, start time, duration).
    • Adds recipients to the appointment.
    • Sets the sending account.
    • Sends the meeting invitation.
    • Cleans up the COM objects to prevent memory leaks.

    P.S

    Replace "user@domino" with the actual email address you want to send from. Modify the recipient list in the $recipients array. Adjust the appointment properties (subject, body, location, start time, duration) as needed.

    Remember to run this script on a machine with Outlook installed and properly configured with the sending account.

    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.