2016 Feb 11 2:53 PM
I'm working on a print program to email packing lists.
If I have multiple email addresses on the customer master, it is only emailing to the first email address on the list.
We want to send to ALL email addresses on the customer master.
I see in the print program where it is creating the RECIPIENT object using function modules
'ADDR_GET_NEXT_COMM_TYPE' and 'CONVERT_COMM_TYPE_DATA'.
I have tried experimenting with other methods to see if I can include multiple email addresses
and had no luck. I'm not sure it is even possible.
My alternative would be to loop through a list of email addresses. Create a RECIPIENT for each
email address one at a time and call the form separately for each recipient.
Before doing this, I was just wondering if there was a better way.
Let me know if there is another solution.
Thanks.
Mike Arnold
2016 Feb 12 8:10 AM
Hi Michael,
You can use class CL_BCS to send mail and here you can attach multiple recipients in TO, CC, BCC as well.
Let me know if you need as illustration on this.
Regards,
Gaurav
2016 Feb 12 2:08 PM
Hi,
Option 2:
If the process is calling function SO_DOCUMENT_SEND_API1 , you can build multiple email addresses in the tables parameter "receivers". Sample code:
data: docdata like sodocchgi1,
objpackt type standard table of sopcklsti1,
objpackt_wa like line of objpackt,
objtxtt type standard table of solisti1,
objtxtt_wa like line of objtxtt,
reclistt type standard table of somlreci1,
reclist_wa like line of reclistt.
loop at gt_email into gt_email_wa.
clear reclist_wa.
reclist_wa-receiver = gt_email_wa-e_email_addr.
reclist_wa-rec_type = c_u.
append reclist_wa to reclistt.
endloop.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = docdata
put_in_outbox = c_x
commit_work = c_x
tables
packing_list = objpackt
contents_txt = objtxtt
receivers = reclistt
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
Regards,
K--
2016 Feb 12 2:25 PM
Keep in mind that this is within the context of creating a Sapscript form.
I have used other function modules in the past and sent to multiple recipients,
but that does not apply in this scenario. The parameter MAIL_RECIPIENT is
an reference to object type RECIPIENT. It seems that this object type only allows
ONE email address and doesn't look like I can do any more.
It looks like I can create an internal table of recipients and issue the sapscript form
for each recipient. That will work, but I was wondering if there was another way of doing it.
* open form
call function 'OPEN_FORM'
exporting
* APPLICATION = 'TX'
archive_index = toa_dara
archive_params = arc_params
device = lvf_device
dialog = ' '
form = tnapr-fonam
language = nast-spras
options = lvs_itcpo
mail_sender = sender_id "LVS_SENDER
mail_recipient = recipient_id "LVS_RECIPIENT
* MAIL_APPL_OBJECT = ' '
* RAW_DATA_INTERFACE = '*'
* IMPORTING
* LANGUAGE =
* NEW_ARCHIVE_PARAMS =
* RESULT =
exceptions
canceled = 1
device = 2
form = 3
options = 4
unclosed = 5
mail_options = 6
archive_error = 7
others = 8.
2016 Feb 12 3:07 PM
Hi Michel,
Your understanding is accurate, That u just get all the recipient's mail address in an Internal table.
And set recipient for send request inside loop on that internal table.