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

Sending multiple emails from one program

arpita_churi3
Active Participant
0 Likes
6,515

Hi All,

  I have developed a program in which I am sending two separate emails to multiple ( same ) recipient using

send method of cl_bcs.

But only first  mail is going and second email is not going.

Pls help.

Thanks,

Arpita

10 REPLIES 10
Read only

Former Member
0 Likes
2,551

Hi,

you can add all the recipients with method add_recipient

  loop at lt_recipient into lo_recipient.
    try.
        call method lo_bcs->add_recipient
          exporting
            i_recipient = lo_recipient.
      catch cx_send_req_bcs .                           "#EC NO_HANDLER
    endtry.
  endloop.

Don't forget a commit work after having called the send method.

If this still doesn't work, you should check if the second recipient is valid. Check transaction SOST.

With best regards,

Hubert


Read only

0 Likes
2,551

My requirement is not to send to mail to multiple recipients but send multiple emails

from same program.

I am able to send only first email second mail is not going even though I have used two separate instances of class cl_bcs.

Thanks,

Arpita

Read only

Former Member
0 Likes
2,551

Hi Arpita,

Do you created two cl_bcs instance?

regards,

Archer

Read only

0 Likes
2,551

No..Only one I am using

Read only

0 Likes
2,551

Hi Arpita,

You need to call all methods from  cl_bcs=>create_persistent( ). to send().

and do a COMMIT WORK for each mail.

example:-

DO 2 times.

     cl_bcs=>create_persistent( ).

     send().

     COMMIT WORK

ENDDO.

Thanks,

Sharath

Read only

tharu
Contributor
0 Likes
2,551

Hi Apita,

Adjust below code according to your requirement..

Try

......

****     --------- set sender -------------------------------------------

****     note: this is necessary only if you want to set the sender

****           different from actual user (SY-UNAME). Otherwise sender is

****           set automatically with actual user.

      sender = cl_sapuser_bcs=>create( sy-uname ).

      CALL METHOD send_request->set_sender

        EXPORTING

          i_sender = sender.

****     --------- add recipient (e-mail address) -----------------------

****     create recipient - please replace e-mail address !!!

      recipient = cl_cam_address_bcs=>create_internet_address(

                                        wa_addsmtp-e_mail ).

*****     add recipient with its respective attributes to send request

      CALL METHOD send_request->add_recipient

        EXPORTING

          i_recipient = recipient

          i_express   = 'X'.

      recipient = cl_cam_address_bcs=>create_internet_address(

                                        'abc@company.com' ).

      CALL METHOD send_request->add_recipient

        EXPORTING

          i_recipient = recipient

          i_express   = 'X'.

      recipient = cl_cam_address_bcs=>create_internet_address(

                                        'xyz@company.com' ).

      CALL METHOD send_request->add_recipient

        EXPORTING

          i_recipient = recipient

          i_express   = 'X'.

****     ---------- send document ---------------------------------------

      CALL METHOD send_request->set_send_immediately( 'X' ).

      CALL METHOD send_request->send(

        EXPORTING

          i_with_error_screen = 'X'

        RECEIVING

          result              = sent_to_all ).

      IF sent_to_all = 'X'.

        WRITE text-003.

      ENDIF.

      COMMIT WORK.

      SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.

    CATCH cx_bcs INTO bcs_exception.

      WRITE: 'Error in Sending Mail.'(001).

      WRITE: 'Error in Sending Mail:'(002), bcs_exception->error_type.

      EXIT.

Endtry.

Thanks

Tharaka

Read only

arpita_churi3
Active Participant
0 Likes
2,551

Hi..

In which format  are you sending document?,...and where is email content?

Read only

0 Likes
2,551

Hi Apita,

Above was a part of full coding..

Please find the text file for coding...

Thanks

Tharaka

Read only

arpita_churi3
Active Participant
0 Likes
2,551

My problem solved..

I am able to send multiple emails to multiple recipients using HTM type (earlier RAW was used so only one email was going at a time)

and formatted email body using html tags.

thanks,

Arpita

Read only

0 Likes
2,551

HI,

Rewards are usefull !!