# Load SMO extension
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$title = 'Email My Scripts'
$msg = 'Enter your INPUT :'
$INPUTVALUEvers = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
$INPUTVALUE = $INPUTVALUEvers -replace '\\','_'
###########Define Variables########
$fromaddress = "xyz@gmail.com"
$toaddress = "xyz@gmail.com"
$Subject = "My report $INPUTVALUEvers"
$body = "My reports"
$smtpserver = "my.com.au"
write-host $INPUTVALUE
$fromaddress = "xyz@gmail.com"
$toaddress = "xyz@gmail.com"
$Subject = "My report $INPUTVALUEvers"
$body = "My reports"
$smtpserver = "my.com.au"
write-host $INPUTVALUE
[array]$attachments =Get-ChildItem -Path "\\My_path\My\*" -Include
MyReport_$INPUTVALUE.html,Mylogon_$INPUTVALUE.txt
$Msg = @{
to = $toaddress
from = $fromaddress
Body = $body
subject = $Subject
smtpserver = $smtpserver
BodyAsHtml = $True
Attachments = $attachments.fullname
}
Send-MailMessage @Msg
$Msg = @{
to = $toaddress
from = $fromaddress
Body = $body
subject = $Subject
smtpserver = $smtpserver
BodyAsHtml = $True
Attachments = $attachments.fullname
}
Send-MailMessage @Msg
No comments:
Post a Comment