Create Outlook email draft using PowerShell

后端 未结 5 1670
清酒与你
清酒与你 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 08:27

    Thought I would add in to this as well. There are a few steps you can save yourself if you know a lot of the basics (subject, recipients, or other aspects). First create the template of the email and save that, e.g. somewhere maybe with the code?

    As to the code itself, it follows much the same that others have posted.

    Borrowing from Jason:

    $ol = New-Object -comObject Outlook.Application
    $msg = $ol.CreateItemFromTemplate(<>)
    

    Modify as needed. Append fields or modify body. The message can still be viewed prior to sending the same way $msg.GetInspector.Display(). Then call $msg.send() to send away!

提交回复
热议问题