Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29904

Powershell query- Could not find a part of the path

$
0
0

I am trying to work on a power shell script to query email id's from a csv list and send out bulk personalized emails.Both the csv file and the script are located on the desktop in the same folder(\DECSRV02\Folder Redirection\paranjyoti\Desktop\Powershell_massemail). The script contains the csv import as :

$csv = Import-Csv 'C:\Users\paranjyoti\Desktop\Powershell_massemail\UserList.csv'
$Credential = Get-Credential
Foreach($Message in $csv){
$Recipient = $Message.EmailAddress
$FirstName = $Message.FirstName
$LastName = $Message.Surname
$Course = $Message.Course
$Grade = $Message.Grade
$Subject = "$FirstName $LastName - $Course Exam Result"
Write-Host "Sending email to $FirstName $LastName"
Write-Host "Email Address: $Recipient"
$mailBody = 
@"
Hello $FirstName,</br>
We have marked your recent exam and the results are as follows:</br>
</br>
Student Name: $LastName, $FirstName</br>
Course: $Course</br>
Result: $Grade</br>
</br>
Thank you for taking a course at our school,</br>
The Faculty
"@

Send-MailMessage -Body $mailBody -BodyAsHtml `
-From "faculty@greatschool.com" -To $Recipient `
-Subject $subject -Encoding $([System.Text.Encoding]::UTF8) `
-Credential $Credential -SmtpServer "smtp.office365.com" -UseSSLcopy
}

While running the script, the error comes up as "Could not find a part of the path"The attached error message image is shown Please can you help in identifying the error.


Viewing all articles
Browse latest Browse all 29904

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>