Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Hello Techbie’s,

I had a requirement to send email with attachment in bods.

I read through some of the article in SCN but none of it provided a detailed way of achieving it.


I found the article (Add an attachment to BODS Job Notification email using VB Script ) somewhat interesting but it was not working for me

So I did a little research and came up with a solution that can be implemented in BODS.

Solution:-

We’ll do it using vb script and then calling that script in our job.

Step 1: Use below code to make a vb script file.

Open a notepad, write below code by making necessary changes to highlighted text and then save it as email.vbs


Option Explicit
Dim MyEmail

Set MyEmail=CreateObject("CDO.Message")

MyEmail.Subject =
"Subject Line"
MyEmail.From =
"no-reply@yourcompany.com"
MyEmail.To =
" helpdesk@yourcompany.com "

               MyEmail.TextBody = "This is the message body."
               MyEmail.AddAttachment
"attachment file path"        -- NO EQUAL TO SIGN HERE

(Note: Attachment filepath - This has to be a shared directory or location which is accessible by the DS. Common mistake people include “equal to ‘=’ “sign near Add attachment which results in an error)


MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=
2

'SMTP Server
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")=
"smtp relay server name"

'SMTP Port
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=
25

MyEmail.Configuration.Fields.Update
MyEmail.Send

set MyEmail=nothing

Step 2: In Job place the below script:

Script_Email which includes a call to email.vbs script file:

                          

                    e.g.        exec('cscript','filepath\email1.vbs', 8);

            Filepath where email.vbs is located.

10 Comments
Labels in this area