Why is My Batch File Not Sending Email?

While the CopyStorm Batch File can be configured to send email, the best practice is generally to use CopyStorm’s built-in notification settings.


The CopyStorm Batch File tab will generate a script that is useful for running CopyStorm in batch mode. Although the script generator asks for email addresses to notify on CopyStorm success and failure, some installation configurations may cause the generated script to not successfully send a Salesforce backup notification email.

The Batch File tab will generate scripts in a variety of languages. Some of these languages have a built-in way to send email in an operating system independent way, but some do not. When a scripting language (like BAT) does not have a built-in way to send an email then it is the responsibility of the script to implement the behavior.

See the following sections for help with each batch script type.

Hints On Using a Generated BAT File

There is no standard way to send an email from a Windows BAT file, and CopyStorm does not try to guess the technique used by your organization. Generated BAT scripts isolate the “email sending” code to a small subroutine that must be implemented according to your company standard. At the end of a BAT script generated by CopyStorm you will see code that looks like:

:SendEmail
REM
REM Code your site specific email rule procedure here.
REM
REM %1 is the email subject
REM %2 is the email address that should receive the mail
REM %3 is a file containing the body of the email
REM

ECHO TODO: Send email to %2 with subject %1
EXIT /B

This code is a subroutine that the script will call each time it attempts to send a Salesforce backup notification email. To finish the script, you need to implement your organization’s email sending logic. BAT  file emailing is accomplished using a number of techniques, varying by organization:

  • Copying the log file to a directory using a name that indicates when the job completed.
  • Using the open source tool BLAT to email the status.

The following screenshot indicates where the script changes must be made:

Hints On Using a Generated VBS Script

Windows VBS has a built-in way to send an email if the name of an email server is specified. The default email server is GOING TO BE WRONG all of the time, and CopyStorm has no way to guess the correct server. The aspmx.l.google.com server name must be replaced by the name of your company’s email server.

  • aspmx.l.google.com is a well-known server that will process email addressed to gmail accounts.

The following screenshot indicates the values that must be changed to match your environment:

Hints On Using a Generated BASH Script

The rules for using a BASH script are the same as those for a VBS script — two values must be changed before generating the script:

  • EMail Server
  • EMail From

See the screenshot under the VBS section above for an example.

Hints On Using a Generated Python Script

The rules for using a Python script are the same as those for a VBS script — two values must be changed before generating the script:

  • EMail Server
  • EMail From

See the screenshot under the VBS section above for an example.