Skip to Content
avatar image
Former Member

SO_NEW_DOCUMENT_SEND_API1 multiple recipients

Hi,

I am using SO_NEW_DOCUMENT_SEND_API1 and it is working fine for me if there is one recipient.

Now I want to send the email to more than one recipient, so I just added the additional recipients into the table LT_MAILRECIPIENTS.

LT_MAILRECIPIENTS-REC_TYPE  = 'U'.
LT_MAILRECIPIENTS-RECEIVER = 'email1address'.
APPEND LT_MAILRECIPIENTS .
LT_MAILRECIPIENTS-RECEIVER = 'email2address'.
APPEND LT_MAILRECIPIENTS .
CLEAR LT_MAILRECIPIENTS.

Now if I call the function, it will only send to the first recipient in the table!

I tried to do a loop at LT_MAILRECIPIENTS and then call the function. Then it will send to all of them, but in the above case, every recipient will receive 2 emails instead of only 1.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA              = LT_MAILSUBJECT
      TABLES
        OBJECT_CONTENT             = LT_MAILTXT
        RECEIVERS                  = LT_MAILRECIPIENTS
      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.
      COMMIT WORK.

Any suggestions how I can send the email to all recipients in my table?

Thanks

Anne

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Sep 13, 2010 at 02:00 PM

    Go through this already available program on Wiki carefully, i hope it will help you solve your problem.

    [http://wiki.sdn.sap.com/wiki/display/Snippets/SendMultipleAttachmentsofSpoolwithE-mail]

    Regards

    Abhii

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 13, 2010 at 02:15 PM

    Your code seems to be fine.

    How is LT_MAILRECIPIENTS declared ?

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 13, 2010 at 02:16 PM

    Try this code.

    LT_MAILRECIPIENTS-REC_TYPE  = 'U'.
    LT_MAILRECIPIENTS-RECEIVER = 'email1address'.
    APPEND LT_MAILRECIPIENTS .
    
    LT_MAILRECIPIENTS-REC_TYPE  = 'U'.
    LT_MAILRECIPIENTS-RECEIVER = 'email2address'.
    APPEND LT_MAILRECIPIENTS .
    
    
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
          EXPORTING
            DOCUMENT_DATA              = LT_MAILSUBJECT
          TABLES
            OBJECT_CONTENT             = LT_MAILTXT
            RECEIVERS                  = LT_MAILRECIPIENTS
          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.
          COMMIT WORK.
        ENDIF.
    

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 13, 2010 at 02:18 PM

    Hello Anne,

    you can refer to this link, it is talking about the same topic as yours.

    how to send mails to multiple recipents using SO_DOCUMENT_SEND_API

    Best Regards,

    Jerry

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 13, 2010 at 02:19 PM

    Just a try,

    pass it like

    RECEIVERS = LT_MAILRECIPIENTS[].

    Its time to get rid of header lines 😊

    Instead of this fm i suggest you to use the BCS classes available. This fm doesnt support certain code pages.

    For BCS classes example sin SE38 just search for BCSEXAMPLE

    @gautham - I dont see any difference in OP's code and yours 😉

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 13, 2010 at 04:39 PM

    In debug, look at the contents of your recipient table and be sure it is correct. See SAP Note 609696 for update documentation and working code, should you decide to continue to use this out-of-date method for email.

    Add comment
    10|10000 characters needed characters exceeded