Page 1 of 1
using parameters within an e-mail test message
Posted: Tue Sep 20, 2005 9:41 am
by EJRoufs
Using Windows Servers, and DataStage version 7.1
We are using parameters to change things like dates and such throughout our jobs. The one place we're having a problem getting the parameter to work is within the e-mail notification stage we use within DataStage Sequencer jobs. We have some e-mail notifications that go out, and these notifications include the dates that we change with our parameters. Is there a way to use the parameters within the "e-mail body" itself?
Posted: Tue Sep 20, 2005 10:00 am
by chulett
Only by writing your own email handling routine, for some silly reason the stage doesn't support this functionality.
Re: using parameters within an e-mail test message
Posted: Tue Sep 20, 2005 10:53 am
by DeepakCorning
Yeah , I have the same problem , The DSSENDMAIL doesn't support to attach parameters in it.
I dont know wht can be the workout.
Posted: Tue Sep 20, 2005 4:57 pm
by ray.wurlod
It's better in version 7.5.
Posted: Thu Sep 22, 2005 1:02 pm
by EJRoufs
ray.wurlod wrote:It's better in version 7.5.
So when we upgrade to 7.5 in a few months here, I can use the parameters within then?
Posted: Thu Sep 22, 2005 1:07 pm
by chulett
No, but you can do attachments.
![Wink :wink:](./images/smilies/icon_wink.gif)
Posted: Sat Sep 24, 2005 4:53 pm
by roy
Hi,
I usually use a routine or a basic job control for notification activities even in 7.5 where you can use parameters simply since usually you need more then just mail notifications.
This way your not limited and any further activity is added effortlessly.
IHTH,
Posted: Sat Sep 24, 2005 8:56 pm
by kduke
Here is a routine which can be used in a routine activity which can be sent parameters. I will add this to my tips page soon.
Code: Select all
* -----------------------------------------------------------------
* EtlSendMail(EmailTo, EmailFrom, EmailServer, EmailSubject, EmailMsg)
* -----------------------------------------------------------------
* Arguments:
* 1. EmailTo
* 2. EmailFrom
* 3. EmailServer
* 4. EmailSubject
* 5. EmailMsg
* -----------------------------------------------------------------
* Decription: Email msg to someone.
* -----------------------------------------------------------------
* Written by: Kim Duke
* -----------------------------------------------------------------
* Notes:
* -----------------------------------------------------------------
$INCLUDE DSINCLUDE JOBCONTROL.H
Ans = @TRUE
RoutineName = "EtlSendMail"
ThisDay = convert('-','',oconv(@DATE, "D4-YMD[4,2,2]"))
ThisTime = convert('-','',oconv(@TIME, "MTHS"))
CrLf = Char(13):Char(10)
Host = upcase(DSHostName)
ProjectType = "DEV"
Begin case
case Host = "DSDEV"
ProjectType = "DEV"
case Host = "DSTEST"
ProjectType = "TEST"
case Host = "DSPROD"
ProjectType = "PROD"
end case
NoArgs = 5
for i = 1 to NoArgs
* -----------------------------------------------------------------
* fix defaults
* -----------------------------------------------------------------
begin case
case i = 1
if EmailTo = "" then
EmailToX = "DSX@hotmail.com"
end else
EmailToX = EmailTo
end
if ProjectType = "DEV" or ProjectType = "TEST" then
EmailToX = "DSX@hotmail.com"
end
tmp = EmailToX
gosub DelOutCrLf
case i = 2
if EmailFrom = "" then
EmailFromX = "DSX@hotmail.com"
end else
EmailFromX = EmailFrom
end
if ProjectType = "DEV" or ProjectType = "TEST" then
EmailFromX = "DSX@hotmail.com"
end
tmp = EmailFromX
gosub DelOutCrLf
case i = 3
if EmailServer = "" then
EmailServerX = "MailServer"
end else
EmailServerX = EmailServer
end
tmp = EmailServerX
gosub DelOutCrLf
case i = 4
if EmailSubject = "" then
EmailSubjectX = "Message from: ": ProjectType :" ": DSJobName :" on ": ThisDay :" ": ThisTime
end else
if ProjectType = "PROD" then
EmailSubjectX = EmailSubject
end else
EmailSubjectX = ProjectType :" Job: ": DSJobName :" ": EmailSubject
end
end
tmp = EmailSubjectX
gosub DelOutCrLf
case i = 5
if EmailMsg = "" then
EmailMsgX = ""
EmailMsgX := "Server: ": Host : CrLf
EmailMsgX := "Project: ": @WHO : CrLf
EmailMsgX := "Job: ": DSJobName : CrLf
EmailMsgX := "User: ": @LOGNAME : CrLf
EmailMsgX := "Date: ": ThisDay : CrLf
EmailMsgX := "Time: ": ThisTime : CrLf
EmailMsgX := "EmailServer: ": EmailServerX : CrLf
EmailMsgX := "EmailFrom: ": EmailFromX : CrLf
EmailMsgX := "EmailTo: ": EmailFromX : CrLf
end else
EmailMsgX = EmailMsg
end
tmp = EmailMsgX
gosub ChangeOutCrLf
end case
* -----------------------------------------------------------------
* gosub forced to retunr to here
* -----------------------------------------------------------------
ReturnHere:
* -----------------------------------------------------------------
* fix CrLf turn into \n
* -----------------------------------------------------------------
begin case
case i = 1
EmailToX = tmp
case i = 2
EmailFromX = tmp
case i = 3
EmailServerX = tmp
case i = 4
EmailSubjectX = tmp
case i = 5
EmailMsgX = tmp
end case
next i
* -----------------------------------------------------------------
* test data
* -----------------------------------------------------------------
DSSendMailString = "To:": EmailToX : "\n"
DSSendMailString := "From:": EmailFromX : "\n"
DSSendMailString := "Subject:": EmailSubjectX : "\n"
DSSendMailString := "Server:": EmailServerX : "\n"
DSSendMailString := "Body:": EmailMsgX : "\n"
Call DSLogInfo(DSSendMailString, DSJobName)
Call DSSendMail("", DSSendMailString)
goto TheEnd
* -----------------------------------------------------------------
* del CrLf
* -----------------------------------------------------------------
DelOutCrLf:
tmp = change(tmp, CrLf, ";")
tmp = change(tmp, Char(13), ";")
tmp = change(tmp, Char(10), ";")
tmp = change(tmp, @FM, ";")
tmp = change(tmp, @VM, " ")
tmp = change(tmp, @SVM, " ")
tmp = change(tmp, @TM, " ")
return to ReturnHere
* -----------------------------------------------------------------
* fix CrLf turn into \n
* -----------------------------------------------------------------
ChangeOutCrLf:
tmp = change(tmp, CrLf, "\n")
tmp = change(tmp, Char(13), "\n")
tmp = change(tmp, Char(10), "\n")
tmp = change(tmp, @FM, "\n")
tmp = change(tmp, @VM, " ")
tmp = change(tmp, @SVM, " ")
tmp = change(tmp, @TM, " ")
return to ReturnHere
* -----------------------------------------------------------------
* end of routine
* -----------------------------------------------------------------
TheEnd:
Re: using parameters within an e-mail test message
Posted: Fri Jan 13, 2006 8:34 pm
by MTCHONG
DeepakCorning wrote:Yeah , I have the same problem , The DSSENDMAIL doesn't support to attach parameters in it.
I dont know wht can be the workout.
You can use parameters with DSSENDMAIL in 7.1 version , for example in the body you can write :
"Rejects in file ": SrcDir:FileName:"."
or in the Smtp Server Mail block :
"":SmtpServer:""
It's the same syntax than in job control (Basic Universe)
But I have one problem, when I import my jobs in the 7.5 version, the DSSENDMAIL doesn't work anymore... and I don't want to modify all my jobs !!!!
Does someone have any idea or patch !!
I think I'll have to ask the Ascential support... Help please!
Posted: Fri Jan 13, 2006 9:16 pm
by chulett
What about 'the DSSENDMAIL' doesn't work? You really should start a new post rather than jump on the end of an old one so we have some clue what your specs are. What operating system?
Posted: Mon Jan 16, 2006 10:43 am
by MTCHONG
chulett wrote:What about 'the DSSENDMAIL' doesn't work? You really should start a new post rather than jump on the end of an old one so we have some clue what your specs are. What operating system?
Hello,
I have started a new post 'DSSENDMAIL upgrade 7.1 to 7.5 ' like you said. Have you got some solutions ?
Thanks a lot.