E=mc2
asked on
Modify Powershell script to send .html attachments
I would like to modify the script so that any html files it finds at this path:
"C:\Users\User1\Desktop\Path
that start with "Desktop-123-Files.... "...
Are sent as attachments with the email.
If there are 2 or 3 html files that all start with the designation above, they should be sent as attachments.
Is this possible?
"C:\Users\User1\Desktop\Path
that start with "Desktop-123-Files.... "...
Are sent as attachments with the email.
If there are 2 or 3 html files that all start with the designation above, they should be sent as attachments.
Is this possible?
#Send Email
$EncryptedCredential = "C:\creds\creds.txt"
$EmailUsername = "email1@email.com"
$EncryptedPW = Get-Content $EncryptedCredential | ConvertTo-SecureString
$Credential = New-Object System.Management.Automation.PsCredential($EmailUsername, $EncryptedPW)
$EmailFrom = "email1@email.com"
$EmailTo = "email1@email.com"
$SMTPServer = "smtp.smtp.com"
$SMTPPort = 123
$subject = "Files Processed"
$SMTPSsl = $true
$param = @{
SmtpServer = $SMTPServer
Port = $SMTPPort
UseSsl = $SMTPSsl
Credential = $Credential
From = $EmailFrom
To = $EmailTo
Subject = $subject
}
Send-MailMessage @param
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for example
Open in new window
So first you would search the directory for the name pattern your looking for and pass the returned values into an array that you use for attachments .Then add the attachments parameter to your script then set attachments to the array.
Open in new window