In this article we are doing to perform two demonstrations for creating draft emails in Outlook from PowerShell.
Option 1: Create an email draft however you need to open Outlook to see it.
Option 2: Create an email draft but have the email open for you instead of opening Outlook.
Here is the first set of commands (Option 1):
$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()
Here is the second set of commands (Option 2) with 2x extra lines at the end:
$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()
The last two lines for the inspector is what opens up the Outlook shown below:
The lines of code that has the To, Subject and Body info in is what you see above.
Hope it helps.
scripts are working but how can i add the aendername or the .from.
the .from is not available.
but when i used . sendername option or sender email address it show the method does not support