FileWatcher: Script to send emails using free tool blat.net

Discuss our other products here. Get help with installation and running, notify us of bugs, request new features and enhancements.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

FileWatcher: Script to send emails using free tool blat.net

Post by DataMystic Support »

See http://www.blat.net/ for the free download

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>
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

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
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

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
Command: C:\Windows\System32\wscript.exe
Parameters: <full path\>send_email.vbs %FILE%
Post Reply