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

Send mail to multiple users

Former Member
0 Likes
5,007

Dear all,

I'm using FM 'EFG_GEN_SEND_EMAIL' to send an Email, for a single user its working fine, but I want to know is it possible sending the same mail to multiple users with the same FM, I searched the forum for the same & ended up finding no satisfying results. Using FM ''SO_NEW_DOCUMENT_ATT_SEND_API1' we can attain this but I want to know if it is possible with the former FM.

Thanks & Regards

Ajai

1 ACCEPTED SOLUTION
Read only

Rocky1
Product and Topic Expert
Product and Topic Expert
0 Likes
3,689

Hi,

It is not possible to send mail to multiple users using FM 'FG_GEN_SEND_EMAIL' . Please use FM ''SO_NEW_DOCUMENT_ATT_SEND_API1' to send mail.

Thanks & Regards

Rocky Agarwal

<personal contact information removed>

Edited by: Thomas Zloch on Mar 29, 2010 11:41 AM

26 REPLIES 26
Read only

Rocky1
Product and Topic Expert
Product and Topic Expert
0 Likes
3,690

Hi,

It is not possible to send mail to multiple users using FM 'FG_GEN_SEND_EMAIL' . Please use FM ''SO_NEW_DOCUMENT_ATT_SEND_API1' to send mail.

Thanks & Regards

Rocky Agarwal

<personal contact information removed>

Edited by: Thomas Zloch on Mar 29, 2010 11:41 AM

Read only

Former Member
0 Likes
3,689

Dear Rocky Agarwal,

I tried using the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' but was not sent to the ID's..is there any additional settings to be done for using this particular FM??

Read only

Rocky1
Product and Topic Expert
Product and Topic Expert
0 Likes
3,689

Hi,

PFB the code that i have used to send mail. In case you need any additional clarification, please feel free to ask..Hope it will help you:

*To fill the content message
  REFRESH i_message.
  wa_message = l_subject.      "Production Error Log Details for Error Code &
  APPEND wa_message TO i_message.
  CLEAR wa_message.
  wa_message = ' '.
  APPEND wa_message TO i_message.
  CLEAR wa_message.
  wa_message = l_system.
  APPEND wa_message TO i_message.
  CLEAR wa_message.
  wa_message = l_sdate.
  APPEND wa_message TO i_message.
  CLEAR wa_message.
  wa_message = l_message.
  APPEND wa_message TO i_message.
  CLEAR wa_message.
  wa_message = l_description.
  APPEND wa_message TO i_message.
  CLEAR wa_message.
  wa_message = l_count.
  APPEND wa_message TO i_message.
  CLEAR wa_message.
  wa_message = ' '.
  APPEND wa_message TO i_message.
  CLEAR wa_message.
  wa_message = l_message2.
  APPEND wa_message TO i_message.
  CLEAR wa_message.

* To populate the subject/generic message attributes
  wa_doc_data-obj_langu  = sy-langu.
  wa_doc_data-obj_name   = c_objname.
  wa_doc_data-obj_descr  = text-t20. "Production Error Log Details
  wa_doc_data-sensitivty = c_r.


* Fill receipient information

  CLEAR wa_receivers.
  REFRESH i_receivers.

  LOOP AT i_emailid INTO wa_emailid.
    IF wa_emailid-email_id CA c_attherate.  "@
      wa_receivers-receiver = wa_emailid-email_id.
      wa_receivers-rec_type = c_u.  "U
    ELSE.
      TRANSLATE wa_emailid-email_id TO UPPER CASE.
      wa_receivers-receiver = wa_emailid-email_id.
      wa_receivers-rec_type = c_c.  "C
    ENDIF.

    wa_receivers-com_type = c_int.
    wa_receivers-notif_del = c_x.
    wa_receivers-notif_ndel = c_x.
    APPEND wa_receivers TO i_receivers.
    CLEAR wa_receivers.
  ENDLOOP.

* Call the Function Module to send the e-mail alongwith the attachments if any
  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
      document_data              = wa_doc_data
      put_in_outbox              = c_x
      commit_work                = c_x
    IMPORTING
      sent_to_all                = wa_sent_all
    TABLES
      contents_txt               = i_message
      receivers                  = i_receivers
    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.

  IF sy-subrc EQ 0.
    MESSAGE text-t08 TYPE 'S'."Mail(s) Send Successfully
  ELSE.
    MESSAGE text-t09 TYPE 'E'."Error in Sending Mail
  ENDIF.

  REFRESH: 
           i_message[],
           i_receivers[].

Read only

Former Member
0 Likes
3,689

Rocky thanks a lot..it helped..but I'm getting a warning message in sost Waiting for Communications Service.

And the mail is not delivered. What could be the problem? Any idea?

Read only

Former Member
0 Likes
3,689

Ajay,

Have you received msg no 637. If so, then the SAPconnect, transaction SCOT needs to be configured.

Ask your basics team to do the necessary configurations.

Thanks.

Read only

Rocky1
Product and Topic Expert
Product and Topic Expert
0 Likes
3,689

Hi Ajay,

Its not an error. Jst select those mails in sost and click on 'Start send proc. for selection'. Your mail will be send.

Thanks & Regards

Rocky Agarwal

Read only

Former Member
0 Likes
3,689

@ Viji, Message number is 672, Manually wen sent from there it is getting delivered to that address.

@ Rocky, Ya I did try that way & it was successful but this program will run in background so nothing manual has to be there in it Rocky..Any idea how to get rid of this warning??

Read only

Rocky1
Product and Topic Expert
Product and Topic Expert
0 Likes
3,689

Hi Ajay,

All mails will be delivered after some time. Don't worry. It is waiting for communications service to process all mail.

Thanks & Regards

Rocky Agarwal

Read only

Former Member
0 Likes
3,689

Ajay,

Have you sent the mail successfully? If so then it was a time issue.

No need to do any manual actions. Just wait for some more time & it will be send automatically.

Thanks.

Read only

Former Member
0 Likes
3,689

Dear Rocky & Viji,

Thanks a lot both of you!

I have executed the code again will check it after sometime. Hope it resolves..

Awarded points for yo'll

Thanks & Regards

Ajay

Read only

former_member188827
Active Contributor
0 Likes
3,689

try passing recepients in I_TAB_RECIPIENTS parameter

Read only

0 Likes
3,689

Dear Abapuser,

I_TAB_RECIPIENTS parameter in which FM you meant to say??

Read only

0 Likes
3,689

in EFG_GEN_SEND_EMAIL.check optional Tables parameter

Read only

0 Likes
3,689

Dear Abapuser,

It is I_TAB_LINES that is there inside the Tables parameter which is for forming the body of the Email & not for the Address of recipients if I'm not wrong please check.

Read only

0 Likes
3,689

im not talking about i_tab_lines .im suggesting the second Tables parameter which is I_TAB_RECIPIENTS.if you cant see it in your code go to se37 and check Tables interface.Its there as optional Parameter.

CALL FUNCTION 'EFG_GEN_SEND_EMAIL'

EXPORTING

i_title = 'test'

  • I_SENDER = SY-UNAME

i_recipient = 'ABAP'

I_FLG_COMMIT = 'X'

I_FLG_SEND_IMMEDIATELY = 'X'

  • I_FLG_SENDER_IS_UNAME =

tables

i_tab_lines = i_tab_lines

I_TAB_RECIPIENTS = rece......................>check this

EXCEPTIONS

NOT_QUALIFIED = 1

FAILED = 2

OTHERS = 3

.

Edited by: abapuser on Mar 29, 2010 10:11 AM

Read only

0 Likes
3,689

EFG_GEN_SEND_EMAIL does not have a table parameter i_tab_recipients. EFG_GEN_SEND_EMAIL can not send to multiple recipients.

But this FM is just a wrapper for a call of several BCS classes. As there is not business logocal behind its easy to write an own Fm or even mothod which is doing exactly the same and is able to send to multiple recipients.

As you can see there is no logic with the recipient string:

l_smtp_addr = i_recipient.
      l_rcl_recipient =
         cl_cam_address_bcs=>create_internet_address( l_smtp_addr ).

*     add recipient with its respective attributes to send request
      l_rcl_send_req->add_recipient( l_rcl_recipient ).

So even recipients divided by semicolon are not taken into effect.

I would write my own stuff for that.

Read only

0 Likes
3,689

There's nothing like a I_TAB_RECIPIENTS in this FM,

I think I should go with the other FM.

Is there any other possibilities people??

Read only

0 Likes
3,689

Hi Ajay,

For your requirement, plz use SO_NEW_DOCUMENT_ATT_SEND_API1.

GO to SE37 and enter this FM, already a sample code is available at FM documentation.

Copy it to your program, and test with multiple mail ID's. It will work.

Thanks.

Read only

0 Likes
3,689

Hi Ajay,

Normally if a mail needs sent to multiple people, it is better to have a Distribution list created and use this distribution list to send an email out. This also helps in maintainability of the list in case new people need added later.

Regards,

Chen

Read only

former_member434229
Active Participant
0 Likes
3,689

Hi,

Check these links:

Regards,

Ni3

Read only

Former Member
0 Likes
3,689

hi,

use below code to send mail to more than one

*For To Address

i_reclist-receiver = '1stmailid'.

i_reclist-rec_type = 'U'.

APPEND i_reclist.

*For Copy Address

i_reclist-receiver = '2ndmailid.com'.

i_reclist-rec_type = 'U'.

i_reclist-copy = 1.

APPEND i_reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

  • document_data = wa_doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = i_objpack

object_header = wa_objhead

contents_bin = i_objbin

contents_txt = i_objtxt

receivers = i_reclist

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.

IF sy-subrc <> 0.

ENDIF.

Regards

Nausal

Read only

Former Member
0 Likes
3,689

Issue was not solved

Read only

Former Member
0 Likes
3,689

Dear Viji & Rocky,

I had kept those mails in the inbox & even after a day the status is still the same, they show waiting status only.

What can possibly be the problem?

Kindly help resolve the issue.

Read only

0 Likes
3,689

Hi Ajay,

Try using the below code after the fm to send mail it would work.

submit rsconn01 with mode = 'INT'

with output = ' '

and return.

Regards,

Neela

Read only

0 Likes
3,689

To avoid manual interaction to finally release the email in SOST a periodically job needs to be stup by yoiur basis team releasing the email. Contact your basic guys if this job is scheduled on a regular basis and ask them for the period this job is running. We are running this job every 5 minutes, so we have to wait 2,2 min in average until the mail is released and sent.

Read only

0 Likes
3,689

Dear all,

I solved the issue after going through this link..It has a very useful demonstrated program.

http://www.sapdev.co.uk/reporting/email/attach_xlsmod.htm

Thanks for all responses

Regards

Ajay