how to do file Attchement option for sending mail

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Roshni
Participant
Posts: 4
Joined: Mon May 09, 2005 3:11 am
Location: Bangalore

how to do file Attchement option for sending mail

Post 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.
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Re: how to do file Attchement option for sending mail

Post 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
In theory there's no difference between theory and practice. In practice there is.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Roshni,

You can attach the files in the Notification Activity Stage in the Job Sequencer.
Thanks,
Naveen
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

...if you have DS 7.5 or above.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

...if you have DS 7.5 or above.
Oops, I forgot to mention that. Thanks Sai for adding it.
Thanks,
Naveen
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post 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
Mamu Kim
Roshni
Participant
Posts: 4
Joined: Mon May 09, 2005 3:11 am
Location: Bangalore

Post by Roshni »

Thank to all for ur suggestions
sudeepmantri
Participant
Posts: 54
Joined: Wed Oct 25, 2006 11:07 pm
Location: Hyderabad

Post by sudeepmantri »

Datastage 7.5.2 and above supports attachemnt.

Syntax

dssendmail("from:sfgsdg\nTo:sggdfg\nSubject:sfgdgdsfg\nAttach:a1,a2\nBody:sfgsdafgsdgd")
Post Reply