09-13-2010 2:49 PM
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
09-13-2010 3: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
09-13-2010 3:15 PM
09-13-2010 3:17 PM
Hi,
this is how LT_MAILRECIPIENTS is declared:
DATA: LT_MAILRECIPIENTS TYPE STANDARD TABLE OF SOMLREC90 WITH HEADER
LINE.
thanks
Anne
09-13-2010 3:20 PM
try this..
data: LT_MAILRECIPIENTS type standard table of SOMLRECI1.
or
DATA: LT_MAILRECIPIENTS TYPE STANDARD TABLE OF SOMLREC90 . "WITH HEADERLINE.
09-13-2010 3:30 PM
Hi,
I tried the following, but it didn't help.
data: LT_MAILRECIPIENTS type standard table of SOMLRECI1 WITH HEADER
LINE.
I just realized that I forgot to copy the last 2 lines of my function call.
* Send Mail
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.
* Push mail out from SAP outbox
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
ENDIF.
Can it have something to do with the line?
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
thanks
Anne
09-13-2010 3:38 PM
data: LT_MAILRECIPIENTS type standard table of SOMLRECI1. " WITH HEADER LINE.
* Send Mail
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.
* Push mail out from SAP outbox
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
ENDIF.
or
2. If you declaring internal table with header line, then pass LT_MAILRECIPIENTS[] to FM as Keshav mentioned.
data: LT_MAILRECIPIENTS type standard table of SOMLRECI1 WITH HEADER LINE.
* Send Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = LT_MAILSUBJECT
TABLES
OBJECT_CONTENT = LT_MAILTXT
RECEIVERS = LT_MAILRECIPIENTS[]. "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.
* Push mail out from SAP outbox
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
ENDIF.
09-13-2010 3:50 PM
Hi gvsastry,
I tried both of your options.
For the first, I cannot activate the code, I get:
"LT_MAILRECIPIENTS" is a table without a header line and therefore has no component called "REC_TYPE".
I can activate the 2nd option, but here I only get one email instead of two.
Thanks
Anne
09-13-2010 3:56 PM
>
> Hi gvsastry,
>
> I tried both of your options.
>
> For the first, I cannot activate the code, I get:
> "LT_MAILRECIPIENTS" is a table without a header line and therefore has no component called "REC_TYPE".
DATA: LS_MAILRECIPIENTS TYPE SOMLRECI1. APPEND LS_MAILRECIPIENTS TO LT_MAILRECIPIENTS.
>
> I can activate the 2nd option, but here I only get one email instead of two.
>
> Thanks
> Anne
I would suggest you debug and see how many entries are present in lt_mailrecipients when you are passing to FM.
09-13-2010 4:09 PM
Hi,
I just debugged and there are two entries in LT[].
The strange thing for me is, when I do the following, everyone in the list gets 2 emails. So it is behaving actually correct with the loop. Of course I don't want 2 emails, but it seems to send to EVERYONE in the list (vs. just for the first one) for each loop. Does that make sense?
LOOP at 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.
* Push mail out from SAP outbox
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
ENDIF.
endloop.
09-13-2010 4:14 PM
09-13-2010 4:32 PM
Ok. Do you have any other suggestions how I could get it to work?
Thanks
Anne
09-13-2010 5:25 PM
09-13-2010 3: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.
09-13-2010 3:18 PM
09-13-2010 3: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
09-13-2010 5: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.