cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Emails from a BSP Application

Former Member
0 Kudos
409

I'm currently trying to send emails from a BSP application.  I've looked at the SAP example BSP program "bsptutorialmail" but it seems when I run the BSP using valid email its does not do anything. Does anyone know of anything else that needs to be configured for this to work? Your help is very much appreciated.

Many Thanks

Gary Ramage

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Gary,

next to the configuration of TX SCOT I use the following coding to create a SMTP e-Mail.

Regards, Bernd

FUNCTION ***_SENT_SMTP_MAIL.

*"----

-


""Lokale Schnittstelle:

*"  IMPORTING

*"     REFERENCE(I_SAV_SMTP_RECEIVER) TYPE AD_SMTPADR

*"     REFERENCE(I_SAV_SUBJECT) TYPE SO_OBJ_DES

*"     REFERENCE(I_SAV_SENDER) TYPE SY-UNAME OPTIONAL

*"     REFERENCE(I_SAV_SMTP_COPY) TYPE AD_SMTPADR OPTIONAL

*"  TABLES

*"      I_TAB_CONTENT TYPE SOLI_TAB

*"  EXCEPTIONS

*"      EMAIL_NOT_SENT

*"----

-


  CLASS ca_sapuser_bcs DEFINITION LOAD.

  CLASS cl_cam_address_bcs DEFINITION LOAD.

  DATA: l_rcl_send_request TYPE REF TO cl_bcs.

  DATA: l_rcl_document TYPE REF TO cl_document_bcs.

  DATA: l_rcl_sender TYPE REF TO cl_sapuser_bcs.

  DATA: l_rif_recipient TYPE REF TO if_recipient_bcs.

  DATA: l_rif_copy TYPE REF TO if_recipient_bcs.

  DATA: l_rcl_bcs_exception TYPE REF TO cx_bcs.

  DATA: l_cnt_num_rows TYPE i.

  DATA: l_cnt_textlength TYPE so_obj_len.

  DATA: l_tab_content TYPE soli_tab.

  DATA: l_sav_sender TYPE sy-uname.

  DATA: l_sav_address TYPE adr6-smtp_addr.

  DATA: l_sav_subject TYPE so_obj_des.

  TRY.

*     Create persistent send request

      l_rcl_send_request = cl_bcs=>create_persistent( ).

*     data conversion is necessary even if Dataelement is the same

      l_tab_content[] = i_tab_content[].

*     Create document

      DESCRIBE TABLE i_tab_content LINES l_cnt_num_rows.

      l_cnt_num_rows = l_cnt_num_rows * 255.

      MOVE l_cnt_num_rows TO l_cnt_textlength.

*     Check for Subject

      IF i_sav_subject IS INITIAL.

        l_sav_subject = 'no subject'.

      ELSE.

        l_sav_subject = i_sav_subject.

      ENDIF.

      l_rcl_document = cl_document_bcs=>create_document(

                          i_type = 'RAW'

                          i_text = l_tab_content

                          i_length = l_cnt_textlength

                          i_subject = l_sav_subject ). "#EC *

*     Add document to send request

      CALL METHOD l_rcl_send_request->set_document( l_rcl_document ).

*     Define Sender - check for import-parameter

      IF i_sav_sender IS NOT INITIAL.

        l_sav_sender = i_sav_sender.

      ELSE.

        l_sav_sender = sy-uname.

      ENDIF.

*     Get sender object

      l_rcl_sender = cl_sapuser_bcs=>create( l_sav_sender ).

*     Add sender

      CALL METHOD l_rcl_send_request->set_sender

        EXPORTING

          i_sender = l_rcl_sender.

*     data conversion is necessary even if Dataelement is the same

      l_sav_address = i_sav_smtp_receiver.

*     Create recipient

      l_rif_recipient = cl_cam_address_bcs=>create_internet_address(

                                                l_sav_address ).

*     Add recipient with its respective attributes to send request

      CALL METHOD l_rcl_send_request->add_recipient

        EXPORTING

          i_recipient = l_rif_recipient

          i_express = ' '

          i_copy = ' '

          i_blind_copy = ' '.

*     Create Copy receiver

      IF i_sav_smtp_copy IS NOT INITIAL.

*     data conversion is necessary even if Dataelement is the same

        l_sav_address = i_sav_smtp_copy.

*     Create recipient

        l_rif_copy = cl_cam_address_bcs=>create_internet_address(

                                                  l_sav_address ).

*     Add recipient with its respective attributes to send request

        CALL METHOD l_rcl_send_request->add_recipient

          EXPORTING

            i_recipient = l_rif_copy

            i_express = ' '

            i_copy = 'X'

            i_blind_copy = ' '.

      ENDIF.

*     Send document

      CALL METHOD l_rcl_send_request->send( ).

      COMMIT WORK.

*   catch errors and raise bapi exception

    CATCH cx_bcs INTO l_rcl_bcs_exception.

      RAISE email_not_sent.

  ENDTRY.

ENDFUNCTION.

TMNielsen
Contributor
0 Kudos

hello all

I was thinking of an other possibility to email stuff, that maybe will give better layout options (font size, boxes etc.) ?

It is possible to output SAPscripts as PDF attached to email, and it should be possible to simply submit a print program (or call Open_form, write_form, close_form directly) from the BSP and send the output via SCOT/SMTP.

Is this a stupid idea ?

Best regards

Thomas Madsen Nielsen

TMNielsen
Contributor
0 Kudos

Hello Gary

In the Web AS General forum i made a posting some time ago where i describe how I installed MiniWAS 6.2.

I also describe configuration needed to send AND receive mails in MiniWAS.

Sending:

1. First step was to make sure I had a working MTA (Mail Transfer Agent). As IIS is included in XP Prof. for free, I chose to use the SMTP server of the IIS. I test that the setup works by sending a mail from outlook express. IIS don?t contain a POP3 so it?s not possible to receive mails in this IIS ? Outlook Express setup.

2. In transaction SCOT I do:

     a) Setting->Default domain : Enter my domain name

     b) In the system status overview: Double click the SMTP node and enter the IP address in the

         Mail host and 25 in the Mail port. Then click on the Set button next to ?Internet? and enter

         an * in the Address area first line

    c) Test setup by creating a mail in SBWP

    d) Start the send process in transaction SCOT by Ctrl+F7 and choose Address Type INT.

    e) When the setup works goto View->and create a new job to automatic run the send process

        periodic

Receiving:

1) The SMTP plugin is listning on port 8025 and I want to keep it that way (to avoid conflict with the IIS smtp server). But the incomming mails arrives on port 25. So, in my firewall I redirect traffic on port 25 to port 8025.

2) In SAP I created a RFC user (User type Communications)

3) In SICF I double-clicked the SAPconnect node - switched to change mode - selected the Service Date tab - and entered the client, user and password of the RFC user

4) After the change was saved I remembered to activate the SAPconnect service again.

You should note that the MiniWAS is semi-pre-configured. A normal SAP WAS system may need more configuration steps. I did not have to change any profile parameters, but you may have to.

Also read the section ?Quick Guide to SMTP Configuration? on help.sap.com.

Happy New Year

Thomas Madsen Nielsen

former_member181879
Active Contributor
0 Kudos

Gary,

All the mail stuff is actually part of the office tools in WebAS, and not part of BSP. The tutoral was just a small example. It would recommend that you check the documentation for the mail stuff (will try to find a link), and also consider to open a OSS message, so that it can be routed to the correct component. Unfortunately, from BSP side, we have no experience with this. One should actually first find a small test program that can test email send/receive with BSP, just to get the configuration correct. (PS: I suspect you must also configure a SMTP service in profile plus transaction SMICM.)

bye, brian

Ulli_Hoffmann
Contributor
0 Kudos

Hi Gary,

for documentation look at:

http://help.sap.com/saphelp_webas620sp25/helpdata/en/58/97c43af280463ee10000000a114084/

content.htm

Setup SMTP is described in note 455140.

Ulli

former_member181879
Active Contributor
0 Kudos

I received the following answer via email:

In this case below it seems that the application can already send its messages to the

outbound queue successfully, probably there's no SAPconnect send job scheduled,

so the messages keep waiting in the queue and nothing happens. As a first hint you may

point Gary to OSS note 455140.

Kind regards, xxx