11-14-2011 7:31 AM
I am facing issue while sending multiple external mails. Its showing a same reciepnt when i am looking in SOST.
Suppose I m sending mail to three recivers under using loop, its showing first email ID of recipent for all three different ID's.
its showing three mail in sost but recipent is same of first for all three mails...
Below is my code
loop at it_mailid into wa_mailid.
lp_email = wa_mailid-EMAIL_ID.
TRY.
lv_recipient = cl_cam_address_bcs=>create_i
CATCH cx_address_bcs INTO lv_cx_address
ENDTRY.
TRY.
CALL METHOD lv_send_request->add_reci
EXPORTING
i_recipient = lv_recipient
i_express = c_true.
CATCH cx_bcs INTO lv_bcs_exception.
ENDTRY.
TRY.
CALL METHOD lv_send_request->send(
EXPORTING
EXPORTING
i_with_error_screen = c_true
RECEIVING
result = lv_sent_to_all ).
endtry.
endloop.
11-14-2011 8:10 AM
Send mail to the distribution/mailing list
form send_email .
try.
-------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
Subject line of the email.
clear line.
*split t_itab_bd-name at space into line line line .
concatenate text-001 t_itab_bd-name
into wa_document_data-obj_descr
separated by space.
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = t_mail_content
i_length = '12'
i_subject = wa_document_data-obj_descr ).
add document to send request
call method send_request->set_document( document ).
--------- 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) -----------------------
Mail to the Bday Name
if not t_itab_bd-mail is initial.
l_email = t_itab_bd-mail.
recipient = cl_cam_address_bcs=>create_internet_address( l_email ).
add recipient with its respective attributes to send request
call method send_request->add_recipient
exporting
i_recipient = recipient
i_express = 'X'.
endif.
List of receivers
IF NOT s_dl[] IS INITIAL.
if not t_itab[] is initial.
loop at t_itab.
l_email = t_itab-mail.
recipient = cl_cam_address_bcs=>create_internet_address( l_email ).
.
add recipient with its respective attributes to send request(CC)
call method send_request->add_recipient
exporting
i_recipient = recipient
i_express = 'X'
i_copy = 'X'.
endloop.
endif.
---------- send document ---------------------------------------
send_request->send_request->set_link_to_outbox( 'X' ).
call method send_request->send( ).
CALL METHOD send_request->edit(
i_hide_note = 'X'
i_starting_at_x = 12
i_starting_at_y = 5
i_ending_at_x = 97
i_ending_at_y = 22 ).
commit work.
submit rsconn01 with mode eq 'INT' and return.
-----------------------------------------------------------
* exception handling
-----------------------------------------------------------
* replace this very rudimentary exception handling
* with your own one !!!
-----------------------------------------------------------
catch cx_bcs into bcs_exception.
write: 'Fehler aufgetreten.'(001).
write: 'Fehlertyp:'(002), bcs_exception->error_type.
exit.
endtry.
endform.
Try this code.
11-14-2011 8:53 AM
Hi,
Check if your internal table containing the recipents is refreshed everytime with the new value. Seems there is no clear statement before you populate.
Regards
senthil.