Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem on sending email

Former Member
0 Kudos
63

Hi all,

I have a problem trying to send an attached file by email in a form.

This is my form:

FORM f_invio_mail.

DATA: listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.

DATA: listasci LIKE btcsyslog OCCURS 0 WITH HEADER LINE.

DATA: docdata LIKE sodocchgi1.

DATA: objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE.

DATA: reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.

DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.

DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.

DATA: tb_adr6 LIKE adr6 OCCURS 10 WITH HEADER LINE.

DATA: va_request_id LIKE tsp01-rqident.

DATA: tab_lines TYPE i,

doc_size TYPE i,

att_type LIKE soodk-objtp.

CLEAR: listobject, docdata, objpack, reclist, va_request_id,

tab_lines, objhead, objtxt, listasci, tb_adr6.

REFRESH: listobject, objpack, reclist, objhead, objtxt,

listasci, tb_adr6.

OPEN DATASET p_output FOR INPUT IN TEXT MODE ENCODING DEFAULT.

DO.

READ DATASET p_output INTO listasci.

IF sy-subrc NE 0.

EXIT.

ENDIF.

APPEND listasci.

ENDDO.

CLOSE DATASET p_output.

  • Title and Description

docdata-obj_name = 'Prova'.

CONCATENATE 'prova' '-' INTO docdata-obj_descr.

CLEAR objtxt.

APPEND objtxt.

  • Write Packing List (Main)

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.

docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).

CLEAR objpack-transf_bin.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-obj_name = 'TEXT'.

objpack-obj_descr = 'Text mail'.

objpack-body_num = tab_lines.

objpack-doc_type = 'RAW'.

APPEND objpack.

LOOP AT listasci.

objtxt = listasci.

APPEND objtxt.

ENDLOOP.

  • Write Packing List (Attachment)

CLEAR: tab_lines, listasci.

DESCRIBE TABLE listasci LINES tab_lines.

READ TABLE listasci INDEX tab_lines.

objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( listasci ).

objpack-head_start = 2.

objpack-head_num = 0.

objpack-body_start = 2.

objpack-body_num = tab_lines.

objpack-doc_type = 'PDF'.

objpack-obj_name = 'ATTACH'.

CONCATENATE 'descrizione' 'prova' INTO objpack-obj_descr.

APPEND objpack.

  • select smtp_addr up to 1 rows from adr6

  • into reclist-receiver

  • where addrnumber = lfa1-adrnr.

CLEAR reclist.

reclist-receiver = 'xxx.yyy@zzz.com'.

reclist-express = 'X'.

reclist-rec_type = 'U'.

APPEND reclist.

  • endselect.

  • copy recipents

CLEAR reclist.

reclist-receiver = 'aaa.bbb@ccc.com'.

reclist-express = 'X'.

reclist-rec_type = 'U'.

reclist-copy = 'X'.

APPEND reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = docdata

put_in_outbox = 'X'

TABLES

packing_list = objpack

object_header = objhead

contents_txt = objtxt

receivers = 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.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " invio_mail

I have no error messages, but in the transaction SOST i don't see my sending request.

Can you please help me? Thanks all,

Enrico

1 ACCEPTED SOLUTION

Former Member
0 Kudos
34

Hi enrico,

1. Minor mistake.

2. Just pass this parameter also, when calling

'SO_NEW_DOCUMENT_ATT_SEND_API1'

COMMIT_WORK = 'X'

regards,

amit m.

2 REPLIES 2

Former Member
0 Kudos
35

Hi enrico,

1. Minor mistake.

2. Just pass this parameter also, when calling

'SO_NEW_DOCUMENT_ATT_SEND_API1'

COMMIT_WORK = 'X'

regards,

amit m.

0 Kudos
34

ya as amit said you have to click that commit work.

and check in business workplace whether ur mails are there are not

i dnt have much idea about the transaction u have told