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

Problems with CC in email

Former Member
0 Likes
1,025

I have some problems with my coding below.

Table cc_itab contains :

a@b.com

c@d.com

e@f.com

Table to_itab contains :

g@mycompany.com

h@mycompany.com

The emails are sended correctly but when i look at the mails in outlook i see

1st mail : TO : a@b.com

CC : g@mycompany.com;h@mycompany.com

This is still correct but now the problem starts

2nd mail : TO : c@d.com

CC : g@mycompany.com;g@mycompany.com;h@mycompany.com;h@mycompany.com

in cc every email address is used 2 times.

3th mail : TO : e@f.com

CC : g@mycompany.com;g@mycompany.com;g@mycompany.com;h@mycompany.com;h@mycompany.com;h@mycompany.com

in cc every email address is used 3 times.

******************************************************************************************************************

loop at cc_itab.

TRY.

  • Create persistent send request

send_request = cl_bcs=>create_persistent( ).

  • Create document

document = cl_document_bcs=>create_document(

i_type = 'RAW'

i_text = bodytext

  • i_subject = subject ).

i_subject = 'Overview emails of 06/10/2006' ).

  • Add document to send request

CALL METHOD send_request->set_document( document ).

  • Get sender object

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

  • Add sender

CALL METHOD send_request->set_sender

EXPORTING

i_sender = sender.

  • Create recipient TO -> Vendor

CLEAR c_address.

c_address = cc_itab-s_name_text.

CLEAR recipient.

recipient = cl_cam_address_bcs=>create_internet_address( c_address ).

  • Add recipient with its respective attributes to send request

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = ' '

i_copy = ' '

i_blind_copy = ' '.

  • Create recipient CC -> Purchaser

LOOP AT cc_itab.

CLEAR c_address.

c_address = cc_itab-smtp_addr.

CLEAR recipient.

recipient = cl_cam_address_bcs=>create_internet_address( c_address ).

  • Add recipient with its respective attributes to send request

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = ' '

i_copy = 'X'

i_blind_copy = ' '.

ENDLOOP.

  • set send immediately flag

send_request->set_send_immediately( 'X' ).

  • Send document

CALL METHOD send_request->send( ).

COMMIT WORK.

CATCH cx_bcs INTO bcs_exception.

RAISE EXCEPTION bcs_exception.

ENDTRY.

endloop.

5 REPLIES 5
Read only

anversha_s
Active Contributor
0 Likes
815

Hi,

the mail sending is inside the loop.

loop at cc_itab.

In the starting itself each time <b>refresh</b> that recipient internal table <b>that u r passing to email FM</b>

other ways the emails get appended over and over again

endloop.

hiope u got the problem solution

rgds

Anver

if hlped pls mark points

Read only

0 Likes
815

Hi Anversha,

Thanks for your response but the sending of the mail is not in the loop. In the loop recipients are added to the mail.

The loop ends before setting the send immediately flag and before the send of the document.

Rgds,

Eric

Read only

0 Likes
815

In your code it seems you are looping at cc_tab twice..it might be a typo error as you would be looping at to_tab and cc_tab within it.

I would advice to put a break point before you loop at cc_tab and check how many times it is looping around during the iterations !!

Regards

Anurag

Read only

0 Likes
815

hi ,

as anurag, told.

put a break point before your loop, and chk ur receipent innternal table.

some where the values are appending again and again.

rgds

anver

Read only

0 Likes
815

You're wright.

Did use a clear instead of a refresh of the table.

Thank you both.

Didn't mark my thread as a question so a can't give you points. Sorry. Will do it next time.