cancel
Showing results for 
Search instead for 
Did you mean: 

Multple Recipients into SapScript email

Former Member
0 Kudos

Hello

I am trying to send to multiple users a SapScript by this code...



* create sender (current user)
swc_create_object lo_sender 'RECIPIENT' space.
swc_set_element lt_container 'AddressString' sy-uname.
swc_set_element lt_container 'TypeID' 'B'.
swc_call_method lo_sender 'CreateAddress' lt_container.
swc_object_to_persistent lo_sender ls_persistent_sender.

* create recipient
swc_create_object lo_recipient 'RECIPIENT' space.
swc_set_element lt_container 'AddressString' w_correo.
swc_set_element lt_container 'TypeID' 'U'.


SELECT smtp_addr
  INTO w_correo
  FROM adr6
  WHERE addrnumber = w_addrnumber
    AND flgdefault ne 'X'.
swc_set_element lt_container 'SendAsACopy' w_correo.
ENDSELECT.


swc_call_method lo_recipient 'CreateAddress' lt_container.
swc_object_to_persistent lo_recipient ls_persistent_recipient.


ie_mail_sender    = ls_persistent_sender.
ie_mail_recipient = ls_persistent_recipient.

But is not working...how can I do it, any hints??

10nks in advance

Accepted Solutions (0)

Answers (1)

Answers (1)

Sandra_Rossi
Active Contributor
0 Kudos

I think you forgot this line just before creating the recipient:


swc_clear_container lt_container.

Former Member
0 Kudos

Hello Sandra,

What is that for?

Thanks

Gabriel

Sandra_Rossi
Active Contributor
0 Kudos

Apologies, I thought you had to clear the container, but it's useless.

I think you can't send to multiple recipients for a SAPscript:

  • There must be answers in the forum about that.

  • You may also look at the documentation: [SAP library - BCI for sapscript|http://help.sap.com/saphelp_nw2004s/helpdata/en/8d/b0249afbbd11d2a2b300a0c943858e/frameset.htm]

Note: if you'd use your code outside sapscript context, I think there's an error as you should use AddCopyOfRecipient to add a recipient, and SendAsACopy is to be set for the recipients that are to be defined as cc. In your loop, you currently repeat the swc_set_container, it's useless as it will take into account only the last execution. Instead, you should create a recipient, set SendAsACopy and call AddCopyOfRecipient to add it to the message object.

Sandra_Rossi
Active Contributor
0 Kudos

(duplicate removed)