-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemplate_Send_Email_Outlook.ps1
More file actions
47 lines (36 loc) · 974 Bytes
/
Copy pathTemplate_Send_Email_Outlook.ps1
File metadata and controls
47 lines (36 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<#
.SYNOPSIS
.DESCRIPTION
.INPUTS
.EXAMPLE
.COMPONENT
PowerShell, Outlook, ComObject - Outlook.Application
.NOTES
This script is a template of sending an email to somebody using PowerShell and the ComObject - Outlook.Application using Outlook.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory)]
$ParameterName
)
#Outlook must be running for this script to work.
try {
Get-Process -ProcessName OUTLOOK
}
catch {
Start-Process "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" -Wait
}
$My_Signature = @"
"@
$Body = @"
$My_Signature
"@
$outlookComObject = New-Object -ComObject Outlook.Application
$NewMail = $outlookComObject.CreateItem(0)
$NewMail.Subject = ""
$NewMail.Body = $Body
$NewMail.To = "username@domain.com;username@domain.com"
$NewMail.Cc = "username@domain.com;username@domain.com"
$NewMail.Attachments.Add($Attached_File)
$NewMail.Send()
Write-Host "Email has been sent!" -ForegroundColor DarkRed -BackgroundColor Green