troubleshooting Question

Modify Powershell script to send .html attachments

Avatar of E=mc2
E=mc2 asked on
PowershellEmail ClientsScripting Languages
2 Comments1 Solution18 ViewsLast Modified:
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?

#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
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros