$smtpServer = "<Provide your SMTP Server name>"
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "<Provide Your Mail Address>"
$msg.Subject = "Test"
$msg.Body = "< Type the required "
#your file location
$files=Get-ChildItem “<Provide your file location folder >”
Foreach($file in $files)
{
Write-Host “Attaching File :- ” $file
$attachment = New-Object System.Net.Mail.Attachment –ArgumentList C:\newfolder\$file
$msg.Attachments.Add($attachment)
}
$smtp.Send($msg)
$attachment.Dispose();
$msg.Dispose();
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "<Provide Your Mail Address>"
$msg.Subject = "Test"
$msg.Body = "< Type the required "
#your file location
$files=Get-ChildItem “<Provide your file location folder >”
Foreach($file in $files)
{
Write-Host “Attaching File :- ” $file
$attachment = New-Object System.Net.Mail.Attachment –ArgumentList C:\newfolder\$file
$msg.Attachments.Add($attachment)
}
$smtp.Send($msg)
$attachment.Dispose();
$msg.Dispose();
No comments:
Post a Comment