Share via


PowerShell 7.0.3: Create an email message

In another article, we used Windows 10 to create a new email message with PowerShell 5.1 .

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 = "User1@thexchangelab.com"

$TlabEmail.Subject = "Draft email from PowerShell"

$TlabEmail.Body = "PowerShell makes your life easy"

$TlabEmail.save()

https://everything-powershell.com/wp-content/uploads/2020/12/image-21.png

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 = "User1@thexchangelab.com"

$TlabEmail.Subject = "Draft email from PowerShell"

$TlabEmail.Body = "PowerShell makes your life easy"

$TlabEmail.save()

$inspector = $TlabEmail.GetInspector

$inspector.Display()

https://everything-powershell.com/wp-content/uploads/2020/12/image-22.png

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

https://everything-powershell.com/wp-content/uploads/2020/12/image-23.png

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