Published: October 5, 2023 | Reading Time: 7 minutes
$outlook = New-Object -ComObject Outlook.Application $namespace = $outlook.GetNamespace("MAPI") $pstPath = "C:\temp\my_sample.pst" $namespace.AddStore($pstPath) $mail = $outlook.CreateItem(0) # olMailItem $mail.Subject = "Test #1 - Sample Data" $mail.Body = "This is a safe test email generated on $(Get-Date)" $mail.Save()
$outlook.Quit() [System.Runtime.Interopservices.Marshal]::ReleaseComObject($outlook)