In a previous article, we used Windows 10 which has PowerShell 5.1 to create a new email message. Here is the link to the article:

  • https://everything-powershell.com/powershell-create-an-email-using-powershell/

In this article we will perform the same function but we will use PowerShell v7.0.3 instead. We will run with both options as per the first article. Create an email without having the email window open:

$Outlook = New-Object -comObject Outlook.Application
$TlabEmail = $Outlook.CreateItem(0)
$TlabEmail.To = “[email protected]
$TlabEmail.Subject = “Draft email from PowerShell”
$TlabEmail.Body = “PowerShell makes your life easy”
$TlabEmail.save()

Powershell 7.0.3:- create an email message

And now we will do the second one but this one has the Inspector section in it:

$Outlook = New-Object -comObject Outlook.Application
$TlabEmail = $Outlook.CreateItem(0)
$TlabEmail.To = “[email protected]
$TlabEmail.Subject = “Draft email from PowerShell”
$TlabEmail.Body = “PowerShell makes your life easy”
$TlabEmail.save()
$inspector = $TlabEmail.GetInspector
$inspector.Display()

Powershell 7.0.3:- create an email message

and here is the email draft, just like normal PowerShell:

Powershell 7.0.3:- create an email message

and there you have it, PowerShell 7 doing everything that PowerShell 5.1 can do so far..

Hope it helps.

    wpChatIcon

    Discover more from Everything-PowerShell

    Subscribe now to keep reading and get access to the full archive.

    Continue reading