12-26-2011 11:45 PM
you can send mail with one DCL command (see $ HELP MAIL EXAMPLES) like this:
$ MAIL/SUBJECT="..." filename "user@domain"
If you use SYS$INPUT instead of filename, you can put your mail text body into a DCL procedure immediately following the above command.
You can also include mail commands in a DCL procedure like this:
This is the subject line
Then follows the body of the mail message,
12-27-2011 01:03 AM
Thanks, it's working, but I had one more question:
how to put variable into email title, such as:
the value is $val
it does not working.
12-27-2011 01:12 AM
it's not possible to put a variable name into an input stream read from the DCL command file itself and expect that variable name to be substituted with the current value of the variable.
Instead, you can use the one-line MAIL command, which allows you to specify the /SUBJECT string including variables (e.g. /SUBJ="text including ''val' ...", which get substituted or you can create a short DCL procedure file on-the-fly with the necessary values hard-coded,like:
$ OPEN/WRITE x mail.tmp
$ WRITE x "$ mail"
$ WRITE x "send"
$ WRITE x "firstname.lastname@example.org"
$ WRITE x "the value is ''val'"
$ WRITE x "$ EXIT"
$ CLOSE x
$ DELETE/NOLOG/NOCONF mail.tmp;0
12-27-2011 02:17 AM - edited 12-28-2011 12:15 AM
It looks like you compared the DCL input stream with a Unix Here Document. As already said, DCL doesn't do variable expansion but Here Documents do.
01-08-2012 07:16 PM
You can use PIPE to get variables into MAIL messages without the need for temporary files.
$ OUT="WRITE SYS$OUTPUT"
$ Subj="Your Subject"
$ var="Some text"
$ PIPE ( -
OUT "This is the body of the message" ; -
OUT "which may contain variables ''var'" ; -
OUT "or expressions ",count+1 ) | -
MAIL/SUBJECT="''Subj'" SYS$PIPE "''to'" > nl:
The trailing "> nl:" sends the "Enter your message below" prompt to the null device.