Pages

Wednesday, 2 July 2014

Sent Mail to Distribution List Mail

The steps to implement the solution are:
1. Create the distribution list
2. Use the distribution list wherever required

The below screenshots briefly show how to create distribution list. Additional information on this is available at multiple places SCN and SAP help.

Use transaction SO23 / SBWP=> Distribution List to create a distribution list.













Add recipients. Many options are available for adding recipients. 







Use the following code to send the email to a distribution list.
  1. **********************************************************************  
  2. * FORM    :  send_notification  
  3. *********************************************************************  
  4. FORM send_notification .  
  5.   DATA: wa_maildata TYPE sodocchgi1,  
  6.               it_reclist TYPE TABLE OF somlreci1,  
  7.               wa_reclist TYPE  somlreci1.  
  8.   wa_maildata-obj_name = 'TESTOBJ'.  
  9.   wa_maildata-obj_descr = text-030.  
  10.   wa_maildata-sensitivty = 'P'.  
  11.   wa_reclist-receiver = 'ZNR_I0001'.  
  12.   wa_reclist-rec_type = 'C'.  
  13.   APPEND wa_reclist TO it_reclist.  
  14.   CLEAR wa_reclist.  
  15.   wa_mailtxt =  'Do not reply to this system generated email'(032).  
  16.   append wa_mailtxt to it_mailtxt.  
  17.   CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'  
  18.     EXPORTING  
  19.       document_data              = wa_maildata  
  20.       document_type              = 'RAW'  
  21.       put_in_outbox              = 'X'  
  22.       commit_work                = 'X'  
  23.     TABLES  
  24.       object_content             = it_mailtxt  
  25.       receivers                  = it_reclist  
  26.     EXCEPTIONS  
  27.       too_many_receivers         = 1  
  28.       document_not_sent          = 2  
  29.       document_type_not_exist    = 3  
  30.       operation_no_authorization = 4  
  31.       parameter_error            = 5  
  32.       x_error                    = 6  
  33.       enqueue_error              = 7  
  34.       OTHERS                     = 8.  
  35.   IF sy-subrc <> 0.  
  36.     sy-subrc = 0.  
  37.   ENDIF.  
  38. ENDFORM. "send_notification  


Assumptions:
All business users are maintained in the system with correct email addresses.
SCOT configuration is complete and set up to send emails.

No comments:

Post a Comment