-
Notifications
You must be signed in to change notification settings - Fork 4
/
Send Email.ps1
61 lines (47 loc) · 1.67 KB
/
Send Email.ps1
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Function Send-Email{
Param (
<#
.PARAMETER EmailFrom = The senders email address.
#>
[Parameter(Mandatory=$True,Position=0)]
[String]$EmailFrom,
<#
.PARAMETER Emailto = The Recipients email address.
#>
[Parameter(Mandatory=$True,Position=1)]
[String]$EmailTo,
<#
.PARAMETER Subject = The Subject of the email.
#>
[Parameter(Mandatory=$True,Position=2)]
[String]$Subject,
<#
.PARAMETER Body = The body of the email.
#>
[Parameter(Mandatory=$True,Position=3)]
[String]$Body
<#
.PARAMETER SMTPServer = The address of the SMTP server to use. EX : smtp.gmail.com
#>
[Parameter(Mandatory=$True,Position=4)]
[String]$SMTPServer
<#
.PARAMETER SMTPPort = The SMTP port to use.
#>
[Parameter(Mandatory=$True,Position=5)]
[String]$SMTPPort
<#
.PARAMETER Username = The username to send.
#>
[Parameter(Mandatory=$True,Position=6)]
[String]$Username
<# password to send.
#>
[Parameter(Mandatory=$True,Position=7)]
[String]$Password
)
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, $smtpport)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($username, $password);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
}