batch – Search file extension on a windows pc .r2c and Send it automatically to an email address using a bat file?

I found this very useful script for me, but i am missing a search function for a file extension “.r2d” on the D Drive.

Any idea how to include it? to search for files with .r2d ending and send each file automatically when found by email with file name in description and then to delete the batch file after execution

Every time a user want to let search for the file extension he should click on a link download the file execute it.

Thank for the help

i am bit lost on this


SET GmailAccount=
SET GmailPassword=
SET Attachment=

CALL :PowerShell
CD /D “%PowerShellDir%”
Powershell -ExecutionPolicy Bypass -Command “& ‘%PSScript%’ ‘%GmailAccount%’ ‘%GmailPassword%’ ‘%Attachment%'”
IF EXIST “%~FN0” DEL /Q /F “%~FN0”

SET PowerShellDir=C:WindowsSystem32WindowsPowerShellv1.0
SET PSScript=%temp%~tmpSendeMail.ps1
IF EXIST “%PSScript%” DEL /Q /F “%PSScript%”

ECHO $Username = $args(0)>> “%PSScript%”
ECHO $EmailPassword = $args(1)>> “%PSScript%”
ECHO $Attachment = $args(2)>> “%PSScript%”
ECHO >> “%PSScript%”
ECHO $Username = $Username >> “%PSScript%”
ECHO $EmailTo = “” >> “%PSScript%”
ECHO $EmailFrom = “noreply@Whatever.notify” >> “%PSScript%”
ECHO $Subject = “Email Subject” >> “%PSScript%”
ECHO $Body = “Email Body” >> “%PSScript%”
ECHO $SMTPServer = “” >> “%PSScript%”
ECHO $SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom, $EmailTo, $Subject, $Body) >> “%PSScript%”
ECHO $Attachment = New-Object System.Net.Mail.Attachment($Attachment) >> “%PSScript%”
ECHO $SMTPMessage.Attachments.Add($Attachment) >> “%PSScript%”
ECHO $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) >> “%PSScript%”
ECHO $SMTPClient.EnableSsl = $true >> “%PSScript%”
ECHO $SMTPClient.Credentials = New-Object System.Net.NetworkCredential($Username, $EmailPassword) >> “%PSScript%”
ECHO $SMTPClient.Send($SMTPMessage) >> “%PSScript%”