on 04-03-2006 8:14 AM
Hi,
Please tell me on how to send information from sap to external mail box and if possible please send me sample code.
Regards,
Praba.
hi prabhavathi,
see wheather tis code is usefull,
REPORT ZSENDEXTERNAL.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
Creation of the document to be sent
File Name
DOC_CHNG-OBJ_NAME = 'SENDFILE'.
Mail Subject
DOC_CHNG-OBJ_DESCR = 'Send External Mail'.
Mail Contents
OBJTXT = 'Minimum bid : $250000'.
APPEND OBJTXT.
OBJTXT = 'A representation of the pictures up for auction'.
APPEND OBJTXT.
OBJTXT = 'was included as attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creation of the document attachment
(Assume that the data in OBJBIN is in BMP format)
*OBJBIN = ' \O/ '. APPEND OBJBIN.
*OBJBIN = ' | '. APPEND OBJBIN.
*OBJBIN = ' / \ '. APPEND OBJBIN.
*DESCRIBE TABLE OBJBIN LINES TAB_LINES.
*OBJHEAD = 'PICTURE.BMP'.
*APPEND OBJHEAD.
Creation of the entry for the compressed attachment
*OBJPACK-TRANSF_BIN = 'X'.
*OBJPACK-HEAD_START = 1.
*OBJPACK-HEAD_NUM = 1.
*OBJPACK-BODY_START = 1.
*OBJPACK-BODY_NUM = TAB_LINES.
*OBJPACK-DOC_TYPE = 'BMP'.
*OBJPACK-OBJ_NAME = 'PICTURE'.
*OBJPACK-OBJ_DESCR = 'Representation of object 138'.
*OBJPACK-DOC_SIZE = TAB_LINES * 255.
*APPEND OBJPACK.
Completing the recipient list
RECLIST-RECEIVER = 'youremail@sap.com'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
*RECLIST-RECEIVER = 'SAPUSERNAME'.
*RECLIST-REC_TYPE = 'P'.
*APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE 'The document was sent'.
ELSE.
WRITE 'The document could not be sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'No authorization for sending to the specified number',
'of recipients'.
WHEN 2.
WRITE: / 'Document could not be sent to any recipient'.
WHEN 4.
WRITE: / 'No send authorization'.
WHEN OTHERS.
WRITE: / 'Error occurred while sending'.
ENDCASE.
regards,
padma.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use macros to send the file directly to your external mail box
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Refer this thread:
See this link for Starting send process from SAPconnect
http://www.sapdevelopment.co.uk/reporting/email/email_sendproc.htm
http://help.sap.com/saphelp_nw04/helpdata/en/2b/d925bf4b8a11d1894c0000e8323c4f/frameset.htm
http://www.sapdevelopment.co.uk/reporting/email/email_mbody.htm
And this weblog:
/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
Regards,
Gayathri
Message was edited by: Gayathri Hariharan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi prabha,
u have to use the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'
check this code..
REPORT z_email_abap_report.
----
E-mail an Abap report *
----
Author : Michel PIOUD *
Email : mpioud@yahoo.fr HomePage : http://www.geocities.com/mpioud *
----
DATA : w_name TYPE sos04-l_adr_name.
SELECT-OPTIONS :
Recipient address
s_name FOR w_name DEFAULT sy-uname NO INTERVALS.
----
START-OF-SELECTION.
E-mail Abap report
PERFORM f_send_mail.
----
Form f_send_mail
----
FORM f_send_mail.
Data Declaration
DATA:
l_datum(10),
ls_docdata TYPE sodocchgi1,
lt_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
lt_objhead TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objbin TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_reclist TYPE TABLE OF somlreci1 WITH HEADER LINE,
lt_listobject TYPE TABLE OF abaplist WITH HEADER LINE,
l_tab_lines TYPE i,
l_att_type LIKE soodk-objtp.
WRITE sy-datum TO l_datum.
List of Users According to Logon Date and Password Change
NOTE: Create ALI/OTF Document in Spool
SUBMIT rsusr200 WITH valid = 'X'
WITH notvalid = space
WITH unlocked = 'X'
WITH locked = space
EXPORTING LIST TO MEMORY AND RETURN.
Read list from memory into table
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
Error in function module &1
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
Because listobject is of size RAW(1000)
and objbin is of size CHAR(255) we make this table copy
CALL FUNCTION 'TABLE_COMPRESS'
TABLES
in = lt_listobject
out = lt_objbin
EXCEPTIONS
compress_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
Error in function module &1
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
NOTE: Creation of attachment is finished yet.
For your report, the attachment should be placed into table
objtxt for plain text or
objbin for binary content.
Now create the message and send the document.
Create Message Body
Title and Description
ls_docdata-obj_name = 'USERS_LIST'.
CONCATENATE 'List of Users' sy-sysid '-' l_datum "#EC *
INTO ls_docdata-obj_descr SEPARATED BY space.
Main Text
lt_objtxt = 'List of Users According to Logon Date' &
' and Password Change'. "#EC *
APPEND lt_objtxt.
Write Packing List (Main)
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
READ TABLE lt_objtxt INDEX l_tab_lines.
ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
CLEAR lt_objpack-transf_bin.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'RAW'.
APPEND lt_objpack.
Create Message Attachment
Write Packing List (Attachment)
l_att_type = 'ALI'.
DESCRIBE TABLE lt_objbin LINES l_tab_lines.
READ TABLE lt_objbin INDEX l_tab_lines.
lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = l_att_type.
lt_objpack-obj_name = 'ATTACHMENT'.
lt_objpack-obj_descr = 'List_of_Users'. "#EC *
APPEND lt_objpack.
Create receiver list
LOOP AT s_name.
lt_reclist-receiver = s_name-low.
lt_reclist-rec_type = 'B'.
APPEND lt_reclist.
ENDLOOP.
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_docdata
put_in_outbox = ''
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
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.
Document sent
MESSAGE ID 'SO' TYPE 'S' NUMBER '022'.
ELSE.
Document <&> could not be sent
MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
WITH ls_docdata-obj_name.
ENDIF.
ENDFORM. " F_SEND_MAIL
END OF PROGRAM Z_EMAIL_ABAP_REPORT ******************
reward if useful...
Message was edited by: Ashok Kumar Prithiviraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
here is the sample code...
<a href="http://www.sap-img.com/fu016.htm">SAMPLE CODE</a>
hope this is helpful...
regards,
chithra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.