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

Funtion Module to send mails

Former Member
0 Likes
1,248

Hi,

Can you tell me which are all the function module available for sending mails to a distribution list.

Ezhil.

Hi,

Can you tell me which are all the function module available for sending mails to a distribution list.

Ezhil.

11 REPLIES 11
Read only

Former Member
0 Likes
1,204

Hi ,

You can use the following FM

SO_NEW_DOCUMENT_ATT_SEND_API1

Read only

Former Member
0 Likes
1,204

Hi Ezhil,

Below are the FM to send email.

SO_NEW_DOCUMENT_ATT_SEND_API1 - Send with attachment

SO_NEW_DOCUMENT_SEND_API1-

Regards,

Rahul

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,204

Hello Ezhil,

You can use the same FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send emails to Distr. Lists.

In the tables RECEIVERS (structure SOMLRECI1), you have the field REC_TYPE (recipient type) here you have to pass either P (Private distribution list) or C (Shared distribution list).

Hope this helps.

BR,

Suhas

Read only

Former Member
0 Likes
1,204

Hi,

you can use the function module "SO_OBJECT_SEND" which is used for sending mails in SAP system.

Regards,

Pavan.

Read only

Former Member
0 Likes
1,204

Hi,

Create a Distribution list using SO23 and add Users whom to recieve messages.

Use below function module to send the mail.

SO_NEW_DOCUMENT_SEND_API1

Or..

call the function to create the object in the outbox of the sender

SO_OBJECT_INSERT

call the function to send the already created email to the receivers

SO_OBJECT_SEND

Thanks,

Read only

Former Member
0 Likes
1,204

Hi Ezhilhrh,

You can refer to the below code too

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

Thanks

Alis

Read only

Former Member
0 Likes
1,204

I would like to prefer the class CL_BCS to send an email. See reports BCS_EXAMPLE_* in your SAP for demonstration.

Regards,

Florian

Read only

Former Member
0 Likes
1,204

Hi,

Here are some FM :

SO_NEW_DOCUMENT_SEND_API1

sap_new_document_send_api1(send document)

sap_new_document_att_send_api1(send with attachments) .

This is a small program which is used for sending mail.

data : maildata type SODOCCHGI1.

data : mailtxt type table of SOLISTI1 with header line.

data : mailrec type table of SOMLRECI1 with header line.

start-of-selection.

clear : maildata,

mailtxt,

mailrec.

refresh:mailtxt,

mailrec.

maildata-obj_name = 'Test'.

maildata-obj_descr = 'Test'.

maildata-obj_langu = sy-langu.

mailtxt-line = 'This is a test mail'.

append mailtxt.

mailrec-receiver = 'any mailid'

mailrec-rec_type = 'U'.

append mailrec.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = maildata

DOCUMENT_TYPE = 'RAW'

PUT_IN_OUTBOX = ' '

COMMIT_WORK = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

tables

OBJECT_HEADER = mailtxt

OBJECT_CONTENT = mailtxt

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = mailrec

  • 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.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Hope this will work.

Regards,

Dhanalakshmi L

Read only

Former Member
0 Likes
1,204


REPORT  ztest_mail.

  DATA:
    LS_RECEIVERS TYPE SOMLRECI1.

*----------------------------------------------------------------------*
* Structure to hold the email description (subject).                   *
*----------------------------------------------------------------------*
  DATA:
    LS_MAIL_DATA TYPE SODOCCHGI1.

*----------------------------------------------------------------------*
* Structure to hold the content of email body.                         *
*----------------------------------------------------------------------*
  DATA:
    LS_CONTENT TYPE SOLISTI1.

* Internal table declarations...........................................
*----------------------------------------------------------------------*
* Internal table to hold the list of email recepients.                 *
*----------------------------------------------------------------------*
  DATA:
    LT_RECEIVERS TYPE STANDARD TABLE
                   OF SOMLRECI1
              INITIAL SIZE 0.
 PARAMETER:
   P_RECVR TYPE SOMLRECI1-RECEIVER .

  DATA:
    lt_content TYPE STANDARD TABLE
                 OF solisti1
            INITIAL SIZE 0.

  ls_mail_data-obj_descr = text-sub.
  ls_mail_data-obj_name = text-des.


  ls_receivers-receiver = p_recvr.
  ls_receivers-rec_type = 'U'.
  APPEND ls_receivers TO lt_receivers.
  CLEAR ls_receivers.

  CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
    EXPORTING
      document_data              = ls_mail_data
      document_type              = 'RAW'
      commit_work                = 'X'
    TABLES
      object_content             = lt_content
      receivers                  = lt_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 NE 0.
    MESSAGE ID sy-msgid
          TYPE sy-msgty
        NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.                               " IF SY-SUBRC NE 0

Read only

Former Member
0 Likes
1,204

Hi,

See to this link.

Hope it may help you.

Regards,

Revathi Bhoopal.

Read only

Former Member
0 Likes
1,204

Thank you all. Really helpfull