-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathSendMail.ps1
35 lines (32 loc) · 1.76 KB
/
SendMail.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
# How to send a mail in fsc.net
# ...without parameter "-credential ..." windows-logon-user/pass are used - no popup to enter password!
#Send-MailMessage -to "MySelf <[email protected]>" -from "PowerShell <[email protected]>" `
# -subject "PowerShell-Mail-Test" -credential "DOMFSC01\ffmsperners" -smtpserver "ABGZE78E.FSC.NET"
# without password, with attachment
#Send-MailMessage -to "MySelf <[email protected]>" -from "PowerShell <[email protected]>" `
# -subject "PowerShell-Mail-AttachmentTest" -smtpserver "ABGZE78E.FSC.NET" -attachments "D:\text.txt"
# mail-server in "citrix-net"
#Send-MailMessage -to "MySelf <[email protected]>" `
# -from "IAAS Reporting <[email protected]>" `
# -subject "IAAS-Report" `
# -smtpserver "smtp.smc.fsc.net" `
# -attachments ("C:\Dokumente und Einstellungen\Administrator\Desktop\Scripts\StatusList_2012-03-19*.csv"`
# ,"C:\Dokumente und Einstellungen\Administrator\Desktop\Scripts\StatusList_2012-03-19*.csv.summary.txt")
if( $args[0] )
{
$attachments = @(get-childitem "$($args[0])" )
Send-MailMessage -to "MySelf <[email protected]>" `
-from "SendMail-Script <[email protected]>" `
-subject "An attachment was sent" `
-bodyashtml "Hello,<br/><br/>an attachment was appended.<br/><br/>Best regards" `
-smtpserver "smtp.smc.fsc.net" `
-attachments ( $attachments )
}
else
{
Send-MailMessage -to "MySelf <[email protected]>" `
-from "SendMail-Script <[email protected]>" `
-subject "Just a testmail" `
-bodyashtml "Hello,<br/><br/>this is just a testmail.<br/>No files were attached.<br/><br/>Best regards" `
-smtpserver "smtp.smc.fsc.net"
}