cancel
Showing results for 
Search instead for 
Did you mean: 

How to send email from SAP BODS

Former Member
0 Kudos

Dear All,

I am aware function smtp_to and email_to .

But want to know from where we can call these functions in SAP BODS.

Please let me know how to enable email sending from SAP BODS .

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

As Ken, said, these are done using the Script.  Scripts can be added to in various places in a Job (i.e.  Job, Workflow, Catch, Conditional, While Loop, etc.).  It can also be added to any custom functions you want to create.  The syntax is pretty straight forward for both:

smtp_to('someone@somewhere.com', 'Mail Example', 'This is an example of sending email.', 0, 0);

mail_to('someone@someplace.com', 'Mail Example', 'This is an example of sending email.', 0, 0);

The key here, is while this is all you need in a job to send a message, you need to the Job Servers to be configured for mail.  This is done by who ever is managing your Job Servers.

This is done in the Data Services Server Manager.  The SMTP settings for smtp_to function are on the Miscellaneous tab.  There you specify the Server & Sender.

If you don't have access to that, there are other ways to send email.  If a database you are using (like SQL Server for example) has mail capabilities you can utilize that in the same way you would send email in a query.  We have at times done this as we needed to send datasets in the email and it worked out as SQL Server allows you to send query results as part of the email (whereas the smtp_to function doesn't do that).

Hope that adds to what Ken also stated.

former_member200473
Contributor
0 Kudos

Hi Jason,

Thanks for your inputs.

could you please show one example(either by SQL server or BODS) with screenshot for settings.

This would be great act from your end.

Regards,

Shiva

Former Member

Shiva,

Sure here is a screenshot of a job, with examples.

Also, here is a screenshot from the Data Services Manager where you indicate the smtp server info.

Hope this helps out!

Jason

former_member200473
Contributor
0 Kudos

Jason,

Thanks for your reply

Regards,

Shiva Sahu

Answers (1)

Answers (1)

former_member202087
Active Participant
0 Kudos

These functions can genuinely be called only in a script and are typically used in the catch block of a job to report errors.  The Data Services Reference Guide can give you more specifics but you must have a mail client running on the data services job server to use mail_to.  When using either you will want to make sure the servers are not blocked from sending emails (like in dev or QA environments).   

Former Member
0 Kudos

Dear  Ken,

Thanks Ken , for your quick response.

This information has really helped me..

Small doubt is there on usages of 'try and catch ' .

I want to receive mail only on job failure.

thanks

Anupam

former_member202087
Active Participant
0 Kudos

In your catch block you would mark the exceptions for which you want emails.  These are categorized like Execution errors, database access errors, etc.

The script in your catch block would look something like this...

smtp_to('someone@somewhere.com,someoneelse@somewhereelse.com',

'Data Service error number: '||error_number(),

'Error Message: '||error_message(),20,40);

The email will only be generated if the job fails with one of the categories of errors you selected.