Create Outlook email draft using PowerShell

后端 未结 5 1669
清酒与你
清酒与你 2020-12-03 07:43

I\'m creating a PowerShell script to automate a process at work. This process requires an email to be filled in and sent to someone else. The email will always roughly fol

5条回答
  •  时光说笑
    2020-12-03 08:25

    Based on the other answers, I have trimmed down the code a bit and use

    $ol = New-Object -comObject Outlook.Application
    
    $mail = $ol.CreateItem(0)
    $mail.Subject = ""
    $mail.Body = ""
    $mail.save()
    
    $inspector = $mail.GetInspector
    $inspector.Display()
    

    This removes the unnecessary step of retrieving the mail from the drafts folder. Incidentally, it also removes an error that occurred in Shay Levy's code when two draft emails had the same subject.

提交回复
热议问题