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

Jairo Javier Baleta Cali 131 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
Outlook
A family of Microsoft email and calendar products.
3,333 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,039 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,446 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,272 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Khaled El-Sayed Mohamed 1,250 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