In addition to what I did here:
Loop Through excel file using Powershell
I want to send a mail with only the files that are transfered, and I got a small problem with that. To do that and foreach file transfered I added the file to a variable $FilenameFR with the script below.
Here is what I tried
#Look for each number in the columns selected
for($j=1; $j -le $rowMax-1; $j++){
$Noria = $sheet.cells.Item($RowNoria+$j, $colNoria).text
$NheSN = $sheet.cells.Item($RowNheSN+$j, $colNheSN).text
$Site = $sheet.cells.Item($RowSite+$j, $colSite).text
if ($Noria -like $SBF -and $NheSN -eq $SN) {
Write-Host ($Noria)
Write-Host ($Site)
write-Host ($NheSN)
If ($Site -eq "TMF" -or $Site -eq "TSF") {
Copy-item "P:\MK_M\$F" -Destination "\\inshare.collab.group.safran\COM\NoriaC\CoC\Test_MK_D\France\"
$FR = $FR + 1 #coutn how many files I transfered
$FilenameFR += $F #here for every file transfered i add it's name to this variable
But when I call $FilenameFR in my mails with this script
$Mail.Body =
"Hello,
You've received $FR files, if you Could please treat the certificates received on your folder in the next few days it would be very good.
Please find the link to the folder below :
....
Thank you for your understanding and have a nice day.
PS. The files are :
"
foreach ($File in $FilenameFR) { # Cette boucle c'est pour avoir un nom de Fichier par ligne dans le mail
$Mail.Body += "$File"
}
$Mail.Send()
}
Instead of getting each file in line a got them one attached to the other.
exemple : File1.pdfFile2.pdfFile3.pdf ...
Can you please help me with that.
If their is anything not clear please tell me and thank you so much for your help
+= "$file"to+= "${file}`n"