Page 1 of 1

Email Notification

Posted: Wed Aug 06, 2008 11:11 am
by somu_june
Hi,

I have requirment like this. I need to send a .csv file attachment in mail when there are records in the file, if there are no records then no need to send the attachment in the mail. Is there a way to find the records present or not in a file before sending an attachment .


Thanks,
Somaraju.

Posted: Wed Aug 06, 2008 11:19 am
by chulett
Sure. You can write a routine to leverage O/S commands to test if a file exists, has records, etc and then decide what to do based on the results. For example branching to one of two Email Notification stages in a Sequence job, one of which includes the attachment and one that doesn't.

If your file contains a header record, size checks become a little trickier. You could also build a generic routine to use DSGetLinkInfo with the DSJ.LINKROWCOUNT InfoType to check to see if the job populating the file sent any records to it. I tend to prefer this approach.

Posted: Wed Aug 06, 2008 9:24 pm
by kduke
If you are using 7.5 or above then email has attachments. Earlier versions need to use blat.exe or some UNIX commands to do the attachments. EtlStats has a routine included to show you how to do it in either UNIX or DOS.

The UNIX diff command can show what has changed. If you can do your diff in SQL then EtlStats can send the results of any SQL command as an attachment. Part of the example sequences include row reports of the jobs run within the sequence.