Page 1 of 1
how to do file Attchement option for sending mail
Posted: Mon Aug 08, 2005 4:12 am
by Roshni
the DSSendMail has the following options:
from
to
server
subject
body
i want to send an error file as an attachment. the dssendmail_template.txt does not contain the Attch option. the file looks like
#! /usr/bin/sh
/usr/sbin/sendmail -t <<////
From: %from%
To: %to%
Subject: %subject%
%body%
////
so when i try to add Attach: option to DSSendMail it gives an error
"The following parameters in the call to DSSendMail were not mentioned in the file 'dssendmail_template.txt': attach "
how do i send an attachment?
Thanks in advance.
Re: how to do file Attchement option for sending mail
Posted: Mon Aug 08, 2005 5:11 am
by ogmios
The only way I've found sofar is to launch a UNIX script and do it yourself, using mule e.g. or using a combination of uuencode/mailx
Ogmios
Posted: Mon Aug 08, 2005 10:27 am
by pnchowdary
Hi Roshni,
You can attach the files in the Notification Activity Stage in the Job Sequencer.
Posted: Mon Aug 08, 2005 11:25 am
by Sainath.Srinivasan
...if you have DS 7.5 or above.
Posted: Mon Aug 08, 2005 1:06 pm
by pnchowdary
...if you have DS 7.5 or above.
Oops, I forgot to mention that. Thanks Sai for adding it.
Posted: Mon Aug 08, 2005 1:08 pm
by kduke
Here is a shell script I use.
Code: Select all
#!/bin/ksh
##
# Email.ksh jobname file1 file2 subject
# Written by: Kim Duke
# To use in DataStage:
# SH Scripts/Email.ksh GenReport KimD/Sql2Html/RtLog1.html Test Log
##
if [ $# -lt 3 ]
then
echo "Usage: $0 kim|all jobname file1 file2 subject"
exit 2
fi
case $1 in
kim2)
USERS="Kim_G_Duke@hotmail.com"
;;
*)
USERS=`echo "$1" | tr ";" " "`
;;
esac
shift
JOBNAME=$1
shift
FILENAME=$1
TMPFILE=/tmp/Email_$$.dat
echo "
$USERS
$JOBNAME has built these html reports.
Thanks.
" > $TMPFILE
# TODAY=`date +%m%d%Y_%H%M%S`
TODAY=`date +%Y%m%d`
CHECKFILE=`basename $FILENAME`
if [ "$FILENAME"x != x -a -f $FILENAME ]
then
echo "Attaching: $FILENAME." >> $TMPFILE
UUEXT=`echo "$CHECKFILE" | cut -d"." -f2 `
UUFILENAME=`echo "$CHECKFILE" | cut -d"." -f1 `
UUFILENAME="${UUFILENAME}${TODAY}.${UUEXT}"
unix2dos $FILENAME | uuencode $UUFILENAME >> $TMPFILE
shift
FILENAME=$1
while [ "$FILENAME"x != x -a -f $FILENAME ]
do
CHECKFILE=`basename $FILENAME`
if [ "$CHECKFILE" = "OurLogo.jpg" ]
then
echo "\nAttaching: $FILENAME." >> $TMPFILE
uuencode $FILENAME $CHECKFILE >> $TMPFILE
else
echo "\nAttaching: $CHCKFILE." >> $TMPFILE
UUEXT=`echo "$CHECKFILE" | cut -d"." -f2 `
UUFILENAME=`echo "$CHECKFILE" | cut -d"." -f1 `
UUFILENAME="${UUFILENAME}${TODAY}.${UUEXT}"
unix2dos $FILENAME | uuencode $UUFILENAME >> $TMPFILE
fi
shift
FILENAME=$1
done
SUBJECT=$*
cat $TMPFILE | mailx -s "$SUBJECT" $USERS
rm $TMPFILE
else
echo "Error: $FILENAME is not a valid filename."
exit 3
fi
Posted: Mon Aug 08, 2005 9:50 pm
by Roshni
Thank to all for ur suggestions
Posted: Thu Oct 26, 2006 11:59 pm
by sudeepmantri
Datastage 7.5.2 and above supports attachemnt.
Syntax
dssendmail("from:sfgsdg\nTo:sggdfg\nSubject:sfgdgdsfg\nAttach:a1,a2\nBody:sfgsdafgsdgd")