FileWatcher: Script to send emails using free tool blat.net
Posted: Fri Aug 05, 2011 4:31 pm
See http://www.blat.net/ for the free download
Syntax: Full syntax: http://www.blat.net/syntax/syntax.html
Remember to put double quotes around the complete path to blat.exe!
Example for use in a batch file with File Watcher
Save as send_email.bat
Remember to put double quotes around the complete path to blat.exe in the batch file!
Command: <full path\>send_email.bat
Parameters: %FILE%
Example for use in a VBScript with File Watcher
Save as send_email.vbs
Command: C:\Windows\System32\wscript.exe
Parameters: <full path\>send_email.vbs %FILE%
Syntax: Full syntax: http://www.blat.net/syntax/syntax.html
Code: Select all
"<complete path\>blat.exe" -to test@test.com -from filewatcher@your.domain -subject "File arrived" -body "Please use it" -attach <filename>
Example for use in a batch file with File Watcher
Save as send_email.bat
Code: Select all
@echo off
rem Used with FileWatcher's command line and the %%FILE%% macro
rem Send mail with this file as the attachment
"<complete path\>blat.exe" -to test@test.com -from filewatcher@your.domain -subject "%1 arrived" -body "Please use it" -attach %1
Command: <full path\>send_email.bat
Parameters: %FILE%
Example for use in a VBScript with File Watcher
Save as send_email.vbs
Code: Select all
Option Explicit
dim objArgs
dim filename
dim folder
dim myRegExp
set myRegExp = New RegExp
myRegExp.IgnoreCase = False 'no need
myRegExp.Global = False 'replace once only
myRegExp.Pattern = "\\[^\\]*$" 'match everything from the last \ to the end of the string
dim WshShell
Function ExecuteWithTerminalOutput(cmd)
Set WshShell = WScript.CreateObject("WScript.Shell")
'use this line to hide the window, and wait until the new process finishes
'useful for debugging
WshShell.Run cmd, 1, true
'use this line below when debugging is not needed
' WshShell.Run cmd,0
ExecuteWithTerminalOutput = 0
End Function
'Set a reference to the arguments
Set objArgs = Wscript.Arguments
for each filename in objArgs
ExecuteWithTerminalOutput( chr(34) + "c:\program files\blat.exe" + chr(34) + " -to test@test.com -from filewatcher@your.domain -subject File_Arrived -body Please_Use_it -attach " + chr(34) + filename + chr(34) )
next
Set WshShell = Nothing
Set myRegExp = Nothing
Set objArgs = Nothing
Parameters: <full path\>send_email.vbs %FILE%