2006 Jul 13 5:53 AM
Hi,
Could somebocdy plaese tell me how to send an email from the SAP system?
In programs how many ways we can send mails?
I just want to know where can i get this complete information from?
2006 Jul 13 6:00 AM
Hi,
You can use the function SO_NEW_DOCUMENT_SEND_API1 for sending a mail to either a SAP user or a external mail address. You just will have to change the TYPE in the table where you specify the mail address.
So, depending on your condition populate the appropriate user type for the function module parameters.
Check the code
REPORT ztest_email .
DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: ENTRIES LIKE SY-TABIX.
DATA: NAME(15).
Fill the document
DOC_CHNG-OBJ_NAME = 'URGENT'.
DOC_CHNG-OBJ_DESCR = 'Read at once !'.
DOC_CHNG-SENSITIVTY = 'P'.
OBJCONT = 'Hey man what are you doing !!!'.
APPEND OBJCONT.
OBJCONT = 'Lets go for movie !'.
APPEND OBJCONT.
DESCRIBE TABLE OBJCONT LINES ENTRIES.
READ TABLE OBJCONT INDEX ENTRIES.
DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).
Fill the receiver list
CLEAR RECLIST.
RECLIST-RECEIVER = 'PCSDEVL'. " replace with <login name>
RECLIST-REC_TYPE = 'B'.
RECLIST-EXPRESS = 'X'.
APPEND RECLIST.
CLEAR RECLIST.
RECLIST-RECEIVER = '[email protected]'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
Send the document
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_TYPE = 'RAW'
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
TABLES
OBJECT_CONTENT = OBJCONT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
LOOP AT RECLIST.
IF RECLIST-RECEIVER = SPACE.
NAME = RECLIST-REC_ID.
ELSE.
NAME = RECLIST-RECEIVER.
ENDIF.
IF RECLIST-RETRN_CODE = 0.
WRITE: / NAME, ': succesfully sent'.
ELSE.
WRITE: / NAME, ': error occured'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receivers specified !'.
WHEN 2.
WRITE: / 'No receiver got the document !'.
WHEN 4.
WRITE: / 'Missing send authority !'.
WHEN OTHERS.
WRITE: / 'Unexpected error occurred !'.
ENDCASE.
Regards,
Mukesh Kumar
Message was edited by: mukesh kumar
Hi,
Could somebocdy plaese tell me how to send an email from the SAP system?
In programs how many ways we can send mails?
I just want to know where can i get this complete information from?
2006 Jul 13 6:00 AM
Hi,
You can use the function SO_NEW_DOCUMENT_SEND_API1 for sending a mail to either a SAP user or a external mail address. You just will have to change the TYPE in the table where you specify the mail address.
So, depending on your condition populate the appropriate user type for the function module parameters.
Check the code
REPORT ztest_email .
DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: ENTRIES LIKE SY-TABIX.
DATA: NAME(15).
Fill the document
DOC_CHNG-OBJ_NAME = 'URGENT'.
DOC_CHNG-OBJ_DESCR = 'Read at once !'.
DOC_CHNG-SENSITIVTY = 'P'.
OBJCONT = 'Hey man what are you doing !!!'.
APPEND OBJCONT.
OBJCONT = 'Lets go for movie !'.
APPEND OBJCONT.
DESCRIBE TABLE OBJCONT LINES ENTRIES.
READ TABLE OBJCONT INDEX ENTRIES.
DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).
Fill the receiver list
CLEAR RECLIST.
RECLIST-RECEIVER = 'PCSDEVL'. " replace with <login name>
RECLIST-REC_TYPE = 'B'.
RECLIST-EXPRESS = 'X'.
APPEND RECLIST.
CLEAR RECLIST.
RECLIST-RECEIVER = '[email protected]'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
Send the document
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_TYPE = 'RAW'
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
TABLES
OBJECT_CONTENT = OBJCONT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
LOOP AT RECLIST.
IF RECLIST-RECEIVER = SPACE.
NAME = RECLIST-REC_ID.
ELSE.
NAME = RECLIST-RECEIVER.
ENDIF.
IF RECLIST-RETRN_CODE = 0.
WRITE: / NAME, ': succesfully sent'.
ELSE.
WRITE: / NAME, ': error occured'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receivers specified !'.
WHEN 2.
WRITE: / 'No receiver got the document !'.
WHEN 4.
WRITE: / 'Missing send authority !'.
WHEN OTHERS.
WRITE: / 'Unexpected error occurred !'.
ENDCASE.
Regards,
Mukesh Kumar
Message was edited by: mukesh kumar
2006 Jul 13 6:01 AM
Hello,
Use FM : SO_NEW_DOCUMENT_SEND_API1 .
Make sure that connection is exists in Transaction : SCOT
Regards,
Naimesh
2006 Jul 13 6:01 AM
Hi Phani ,
see this Fm documentation along with sample program code.
<b>SO_NEW_DOCUMENT_ATT_SEND_API1</b>
and u have to do the setting in SCOT to send request to Xchange Server like Outlook.
useful Tcodes : SCOT.
Regards
Prabhu
2006 Jul 13 6:18 AM
Hi Mukesh/Naimesh/Prabhu,
Thanks for ur reply are ther any other means to send the mails. Just want know.
Cheers.
2006 Jul 13 7:08 AM
Hi Phani ,
in SAP we have only One Address node which is able to Connet Xchange server or any i.e INT---SMTP.
by using this Address node ur able to connect Xchange servers.
any method u will follow , finally u have to touch this address node .
for more info see SCOT.
Regards
prabhu
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |