Ok, I think I have removed all identifiable info...
I have 56 files that need to go to 56 different people. I'm using PS code that I actually got from this site (that question is closed) and for the most part is working great, but I'm getting 4 error messages when running the code everytime, but they seem to be affecting the output differently everytime I run it...
See the first time I ran it, there were 4 files that didn't get sent, which makes sense (4 error messages), but when I run it again, I get the same 4 error messages, but this time only 3 emails didn't go through. To top it off, the three emails that didn't go through this time, did run successfully the first time (which also means that the 4 that didn't go through the first time, did go through the second time). So not sure how to perform route cause analysis on this :(. Anyone have any advise?
PS Code:
$csv = Import-Csv -Delimiter ";" -Path "networkfolder\Dashboard_email.csv" -header "Id","Email"
foreach ($item in $csv) {
$filename = "$($item.id)"
send-mailmessage -to $item.email -attachments $filename -body "Testing <br> Testing" -subject "Testing, may delete after confirming receipt of total count. I will IM when script has completed." -from [email protected] -SmtpServer mailrelay.serverlocation.com -cc [email protected]
}
PS Error Messages:
1
send-mailmessage : The specified string is not in the form required for an e-mail address. At networkfolder\Email testing.ps1:5 char:5 + send-mailmessage -to $item.email -attachments $filename -body "We ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidType: (:) [Send-MailMessage], FormatException + FullyQualifiedErrorId : FormatException,Microsoft.PowerShell.Commands.SendMailMessage 2
send-mailmessage : Could not find file 'U:\Id'. At networkfolder\Email testing.ps1:5 char:5 + send-mailmessage -to $item.email -attachments $filename -body "We ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Send-MailMessage], FileNotFoundException + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.SendMailMessage 3
send-mailmessage : Service not available, closing transmission channel. The server response was: 4.4.1 Connection timed out At Networkfolder\Email testing.ps1:5 char:5 + send-mailmessage -to $item.email -attachments $filename -body "We ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage 4
send-mailmessage : Service not available, closing transmission channel. The server response was: 4.4.1 Connection timed out At Networkfolder\Email testing.ps1:5 char:5 + send-mailmessage -to $item.email -attachments $filename -body "We ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
Also if possible, can anyone tell me how to separate paragraphs? I read that using "
" would do that, but not working for me.
Import-Csv Import-Csv -Delimiter ";" -Path "P:\Sales Finance\Steven\Dashboard_email.csv" -header "Id","Email"
will help us here at least with some dummy values – Prasoon Karunan V