SendEmailNotice

Syntax

SendMailNotice.exe [/d] /? | /m | /h topic | [/c emailConfigFile] [/priority emailPriority] commandLineOptions [attachmentFile [...]]

commandLineOptions

/s subjectText /t emailTemplate.html | emailTemplate.txt [/t ...]

Description

Sends an email notice with optional attachments.   Performs basic text replacement based on standard and user defined parameters in both the Email Subject Line and Message Body.

Used in batch processes to send email notices to recipients on a regular basis.  The following are example uses:

Options

Names Type Expected Value Type Description Allowed in configFile? Default Value
/h, /help Value required String Provide help for specific topics - valid topics are: command options such as 'configFile, subjectTitle, emailTemplate, debug', or 'parameterReplacement' or 'attachmentFile no
/?, /syntax Flag Boolean Provide the syntax for executing this application no
/s, /subjectTitle Value optional String Email Subject Line - Enclose in quotes for embedded spaces
yes
/c, /configFile Value optional String Configuration file to use in place of email commandline options no
/e, /emailTemplate 1 or more values accepted String Email template file - valid extentions are: .html and .txt yes
/i, /importance Value optional String Email Importance - valid values are High, Normal, Low yes normal
/d, /debug Flag Boolean Enable debug output and prompting no false
/m, /mailSetup Flag Boolean Provides a dialog for configuring email server connection properties no false

Examples

The following illustrates sending an email when an application returns an error code.  The email uses an html template and passes a subject title showing the return code.  It also includes an error log attachment.

This example sends an email using a configuration file.

SendMailNotice.exe /c c:\config\MyApp.cfg

The next example sends an email after the run completes, attaching the application run log and a report created by the application.

SendMailNotice.exe /c c:\config\MyApp.cfg MyApp.log MyApp.rpt


Option Details

Option: /debug

Turns on debug mode which displays the command line options and shows the status when processing attachments such as 'file not found', 'size too large', etc.  This option also pauses the application and waits for a response before exiting.

Do not add this option in automated tasks.

Option: /emailTemplate

Use this option to provide an emailTemplate to use as the body of the email.  Requires the path to the file and must end in either: ".html or .txt" extension.

You can include both a .html and a .txt email template.  Depending on the recipient's email capabilities she will receive the type compatible with her email client.

Example: /e template.html /e template.txt /s "EmailSubject" error.log

Contents of template.txt:

$$AppName$$ - System Error - Returncode ($$ReturnCode$$)

Error Notice: An error has occured on server %COMPUTERNAME% at $$CurrentDateTime$$ with the return code: $$ReturnCode$$

You are receiving this message because you have been identified to receive notification of any issues. Files may be attached that contain additional information about the error.

Attached Files:
$$AttachedFiles$$

Replacement Markers:

There are two types of replacement markers allowed in subjectTitles and emailTemplates:  

Results of the substitutions:

Email Body Results:

My Application - System Error - Returncode (32)

Error Notice: An error has occured on server SRVXPS01 at 8/29/2008 11:55:00 AM with the return code: 32

You are receiving this message because you have been identified to receive notification of any issues. Files may be attached that contain additional information about the error.

Attached Files:
error.log

Option: /subjectTitle

Use this option to provide the email subject line.  If it includes embedded spaces use double quotes to enclose.

Example: /e template.html /s "My Email Subject"

Option: /configFile

Provide the path to a configuration file that include the ability to specify emailTemplate, subjectTitle, attachmentFiles, and parameterReplacement.

The options in the configFile override any commandline options plus, adds the ability to specify replacement values for user defined emailTemplate parameter markers.

Parameter Markers:

Are used in an emailTemplate and/or subjectTitle to allow for a generic message that will have it's marker values replaced bythe replacement values.  Markers are identified by $$name$$.

Example: /c config.cfg /emailTemplate email.html /subjectTitle "This email is from $$MyName$$"

Contents of config.cfg:

parameterReplacement MyName="Will Smith"

Results in an email with a subject line of:

"This email is from Will Smith"

configFile Option: attachmentFile

The attachment files can optionally be added to a configFile using: the attachmentFile parameter.  Any files attached using this method are added to the list of attachment files provided on the commandline.

Attachment files on the commandline do not have the switch.  They are added at the end of the commandline arguments.

Example: /c config.cfg /e email.html error.log app.cfg otherfile.doc

Contents of config.cfg:

Results in:

the files c:\reportFile.prn and c:\reportFileToo.prn attached to the email in addition to the files error.log, app.cfg, and otherfile.doc.The email importance is set to High.

configFile Option: parameterReplacement

Used to supply a replacement value for a marker in an emailTemplate and/or subjectTitle

Replacement is case sensitive when searching for marker fields.

They can only be provided in a configFile supplied by the /c options and are used in an emailTemplate and/or subjectTitle to allow for a generic message that will have it's marker values replaced by the replacement values.  Markers are identified by $$name$$.

Example: /c config.cfg /subjectTitle "$$AppName$$ - Results Sent"

Contents of config.cfg:

Results in an email with a subject line of:

"My Application - Results Sent"

Standard Replacement Markers:

The following lists the standard replacement markers supported:

Example:

The following show a command process that initiates SendMailNotice after setting the appName and ReturnCode variables variables

Results in an email with a subject line of:

"My Application has received the following error: {32} on Server SRVXPS01 at 8/22/2008 11:35:36 PM"