Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Send E-mail

Former Member
0 Likes
1,349

Hi to all

i need some help about this .

i've been asked to create a function that send parameters to an vb script file that vb script will send email with the parameters like:

from ,to,attach file and so on.

  • our email is on exchange server we don't use the sap email.

thnaks.

gil.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,297

Hi Gil,

If u find any answer helpful, kindly award points.

Regards,

Amit M.

13 REPLIES 13
Read only

Former Member
0 Likes
1,297

Hi Gil,

1. So what is the problem.

2. Assuming that the VB Script file is

ready (with considers the command line

parameters and sends mail)

3. Just call this Function

GUI_RUN

COMMAND = 'VBSCRIPTFILE'

PARAMETER = 'FROM=ABC@XYZ.COM;TO=ABC.COM; ETC'.

I Hope it helps.

Regards,

Amit M.

Read only

Former Member
0 Likes
1,297

Hi again,

1 Two things are important.

2. Where is the VB script file ?

Front-end

or Application Server ?

BCOS the program/approach will differ.

My previous post was for Front-End.

3. If it is on application server,

then the app server needs to Windows NT, etc.

and not UNIX, AIX etc.

(Bcos VBSCript runs only on Microsofts OS)

Regards,

Amit M.

Read only

0 Likes
1,297

Hi amit,

the VB script file is on the front-end now for tests later on it will be on the Application server.(By the way there is a way to test it on the front-end?? )

the app server is on Windows NT so if i enderstand its not have to be a problem.

thanks for your answers.

Read only

Former Member
0 Likes
1,297

Hi again,

1. Please award points if any reply(s) are useful.

Regards,

Amit M.

Read only

0 Likes
1,297

Hi amit,

By the way there is a way to test it on the front-end??

thanks.

Read only

0 Likes
1,297

Hi amit,

well i try what you write me to do but it always give me an error msg,

maybe if you can take alook on this vbscript code that i want the FM will execute you will have an idea.

Dim From

Dim Destination

Dim Subject

Dim Body

Dim Attachment

Argument

Private Sub Argument

Set objArgs = WScript.Arguments

For I = 0 to objArgs.Count - 1

Select Case objArgs(I)

Case Lcase("-f")

From=objArgs(I+1)

If Check_Address(From)="fail" Then

Msgbox "You didn`t type source address correctly.",vbCritical,"Send Mail"

Exit Sub

End If

Case Lcase("-d")

Destination=objArgs(I+1)

If Check_Address(Destination)="fail" Then

Msgbox "You didn`t type destination address correctly.",vbCritical,"Send Mail"

Exit Sub

End If

'Msgbox Destination

Case Lcase("-s")

Subject=objArgs(I+1)

'Msgbox Subject

Case Lcase("-b")

Body=objArgs(I+1)

'Msgbox Body

Case Lcase("-att")

Attachment=objArgs(I+1)

'Msgbox Attachment

End Select

Next

Send_Mail From, Destination, Subject, Body, Attachment

End Sub

Private Sub Send_Mail(From, Destination, Subject, Body, Attachment)

Dim NewMail

Set NewMail = CreateObject("CDO.Message")

NewMail.From = From

NewMail.To = Destination

NewMail.Subject = Subject

NewMail.Textbody = Body

NewMail.AddAttachment Attachment

NewMail.Send

End Sub

Private Function Check_Address(Mail_Address)

For i = 1 To Len(Mail_Address)

If Mid(Mail_Address, i, 1) = "@" Then

Check_Address = "ok"

Exit Function

Else

Check_Address = "fail"

End If

Next

End Function

notice that the parameters are -f for form field ,-d for to field, -s for subject and so on...

thank you very much for your help...

Message was edited by: Gil Hadida

Read only

0 Likes
1,297

we can also use the FM

GUI_EXEC

Read only

0 Likes
1,297

the second fm that you gave me is run but nothing is happen how i custom my vbscript parameters to the sap fm??

Read only

Former Member
0 Likes
1,297

Hi again,

1. Just call this Function Module

(As already mentioned in my first reply)

CALL FUNCTION 'GUI_RUN'

EXPORTING

command = 'c:\VBSCRIPTFILE.vbs'

PARAMETER = 'FROM=ABC@XYZ.COM;TO=ABC.COM; ETC'

  • CD =

  • IMPORTING

  • RETURNCODE =

.

2. I assume that the VBSCript file has been developed

and it works fine (after taking in the input parameters)

This is the way to test in front-end.

I Hope it helps.

regards,

amit m.

Message was edited by: Amit Mittal

Read only

Former Member
0 Likes
1,297

Hi again,

1. i copied the script file as

d:\ml.vbs

2. then i executed the abap code: (just copy paste)

REPORT abc NO STANDARD PAGE HEADING.

data : s type i.

break-point.

CALL FUNCTION 'GUI_EXEC'

EXPORTING

command = 'D:\ML.VBS'

PARAMETER = '-f abc@abc.com -d def@def.com '

IMPORTING

RETURNCODE = s

.

break-point.

3. It is not giving any error.

regards,

amit m.

Read only

0 Likes
1,297

Hi again,

like you mention It is not giving any error,but does nothing if i run this file from the command prompt it run perfectly after i installed on my machine smtp in the iis.

(now for the test i run it on my local machine.)

thank you very very much.

Read only

0 Likes
1,297

OK,

its work all i have to do is to add cscript before the path of the command like that:

data : s type i.

CALL FUNCTION 'GUI_EXEC'

EXPORTING

command = 'cscript D:\ML1.vbs'

PARAMETER = ' -f from@abc.com -d to@abc.com '

IMPORTING

RETURNCODE = s.

thank you very match for your help.

Message was edited by: Gil Hadida

Read only

Former Member
0 Likes
1,298

Hi Gil,

If u find any answer helpful, kindly award points.

Regards,

Amit M.