Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

problem send attachment with mail

Hello,

I'm coding a program which sends a mail with attachment to an external mail address. The system creates the mail and the attachment, bu the content of the attachment isn 't correct.

this is my code

REPORT  Z_SEND_MAIL.

data: IS_DOCDATA type SODOCCHGI1,
IS_RECEIVERS type SOMLRECI1,
IS_RECEIVERS_COPY type SOMLRECI1,
IT_RECEIVERS type table of SOMLRECI1,
IS_CONTENT type SOLISTI1,
IT_CONTENT type table of SOLISTI1,
*500369789+
l_txt(255) type c,
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,
l_tab_lines TYPE i,
l_att_type LIKE soodk-objtp.
*500369789+

IS_DOCDATA-OBJ_NAME = 'MAIL'.
IS_DOCDATA-PRIORITY = 5.
IS_DOCDATA-OBJ_LANGU = SY-LANGU.
IS_DOCDATA-NO_CHANGE = 'X'.
IS_DOCDATA-OBJ_DESCR = SY-CPROG.


clear : IS_CONTENT, l_txt. "500369789+
move '123456789' to l_txt. "500369789+
* move IS_MESSAGE-LINE to IS_CONTENT-LINE. "500369789-
move l_txt to IS_CONTENT-LINE. "500369789+
append IS_CONTENT to IT_CONTENT.

*add receiver
IS_RECEIVERS-RECEIVER = 'mail@mail.com'.
IS_RECEIVERS-REC_TYPE = 'U'.
append IS_RECEIVERS to IT_RECEIVERS.
lt_objhead-line = 'Test mail'.
append lt_objhead.

DESCRIBE TABLE lt_objhead LINES l_tab_lines.
CLEAR lt_objpack-transf_bin.
lt_objpack-doc_size = STRLEN( lt_objhead ).
lt_objpack-head_start = 1.
lt_objpack-head_num = 1.
lt_objpack-body_start = 1.
lt_objpack-body_num = 1.
lt_objpack-doc_type = 'RAW'.
APPEND lt_objpack.
l_att_type = 'TXT'.
DESCRIBE TABLE it_content LINES l_tab_lines.
READ TABLE it_content into is_content INDEX l_tab_lines.
lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255.
lt_objpack-doc_size = lt_objpack-doc_size + STRLEN( is_content ).
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 2.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = l_att_type.
lt_objpack-obj_name = 'ATTACHMENT'.
concatenate 'Test' SY-DATUM+6(2) SY-DATUM+4(2) into
lt_objpack-obj_descr. "#EC *
APPEND lt_objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = IS_DOCDATA
commit_work = 'X'
TABLES
packing_list = lt_objpack
* object_header = lt_objhead
contents_txt = lt_objhead
contents_bin = it_content
receivers = it_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.

The attachment is a TXT, the content should be '123456789', but it is '1 2 3 4'.

Does anyone has an idea why he does this ?

thanks !

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question