Page 1 of 1

eMail attached file if record count is greater than zero

Posted: Thu Jun 29, 2006 2:17 pm
by jandersen
I would like to email a file attachment only if the number of rows is greater than zero.

If someone has done this with Version 7 I would greatly appreciate to know how.

Posted: Thu Jun 29, 2006 2:27 pm
by kris007
As per me, You will have to write a routine where you count the number of records in the file first( one way would be using DSGetLinkInfo and calculate the number of records passing through the link into the sequential file) and then if it is greater than zero call DSSendmail routine in that routine and attach the file. Then you can use this routine in a JobSequence.

Posted: Thu Jun 29, 2006 2:35 pm
by chulett
Or just conditionally link to the Notification Activity stage from there based on the routine's return code.

Posted: Thu Jun 29, 2006 3:03 pm
by DSguru2B
Welcome Aboard 8)

As Kris mentioned, you will need to write a Basic routine to handle this.
Look into your BASIC guide and search for the STATUS command. Your concern will be the 6th field in the dynamic array that the STATUS command returns. Something like

Code: Select all

OPENSEQ Arg1 TO myfile
      ELSE CALL DSLogWarn("Error opening file ":Arg1)
STATUS mystat FROM myfile THEN
Ans =  mystat<6,1,1>
CLOSESEQ myfile
where Arg1 = fully qualified path to your file
It will return you the file size. If it is non zero, then let the flow go to the notification activity with the attachment of the file.

Posted: Thu Jun 29, 2006 3:22 pm
by kris007
DSguru2B wrote:Welcome Aboard 8)
:?
It's been a while jandersen is on board :wink:

Posted: Fri Jun 30, 2006 6:38 am
by DSguru2B
Welcome as in "Congrats in gathering up the courage and posting your very first message". :P
And o yea one more thing, "I saved a bunch of money by switching to geico" :wink:

Posted: Fri Jun 30, 2006 7:03 pm
by kduke
jandersen

Which part do you need help with the email attachment or the getting the row counts?

Re: eMail attached file if record count is greater than zero

Posted: Fri Jun 30, 2006 11:23 pm
by newtier
jandersen wrote:I would like to email a file attachment only if the number of rows is greater than zero.

If someone has done this with Version 7 I would greatly appreciate to know how.
Look in the Routines (from DS Manager), possibly under the Utility or SDK section. There may be an example there (called something like SendEmail).