REPORT zmailsend .
DATA : document_data LIKE sodocchgi1,
packing_list LIKE sopcklsti1,
object_header LIKE solisti1,
contents_bin LIKE solisti1.
DATA : inhalt LIKE solisti1,
contents_hex LIKE solix,
object_para LIKE soparai1,
object_parb LIKE soparbi1,
receivers LIKE somlreci1.
DATA :
t_packing_list LIKE STANDARD TABLE OF packing_list,
t_contents LIKE STANDARD TABLE OF inhalt,
t_receivers LIKE STANDARD TABLE OF receivers.
PARAMETERS : p_rec LIKE somlreci1-receiver
DEFAULT 'kringe.m@t-online.de'.
* DEFAULT 'SAPUSER1'.
START-OF-SELECTION.
CHECK NOT p_rec IS INITIAL.
* das ist der Inhalt der Mail ----------------
CLEAR : t_contents,
inhalt.
inhalt = 'das ist die erste Zeile'.
APPEND inhalt TO t_contents.
CLEAR : inhalt.
inhalt = 'das ist die erste Zeile'.
APPEND inhalt TO t_contents.
* das ist der Inhalt der Mail ------------ENDE
CLEAR : document_data.
document_data-obj_langu = sy-langu.
document_data-obj_name = 'LALALA'.
document_data-obj_descr = 'Das ist die Überschrift'.
document_data-sensitivty = 'F'.
*---->
*P Privates Objekt.
*F Funktionales Objekt.
*O Vertrauliches Objekt.
*C Firmenvertrauliches Objekt
CLEAR packing_list.
REFRESH t_packing_list.
packing_list-transf_bin = space.
packing_list-head_start = 1.
packing_list-head_num = 0.
packing_list-body_start = 1.
* Wieviel Zeilen hat der Inhalt ????
DESCRIBE TABLE t_contents LINES packing_list-body_num.
packing_list-doc_type = 'RAW'.
APPEND packing_list TO t_packing_list.
CLEAR : t_receivers,
receivers.
receivers-receiver = p_rec.
* receivers-rec_type = 'U'. EMAIL !!
* receivers-rec_type = 'B'. SAP-USER !!
receivers-rec_type = 'U'.
*O SAPoffice Benutzer
*B SAP Benutzer
*U Internet Adresse
*X X.400 Adresse
*R SAP Benutzer in einem anderen SAP System
*A externe Adresse
*F Faxnummer
receivers-com_type = 'INT'.
*receivers-com_type =' ' SAPoffice intern
*receivers-com_type = 'TELFAX'
*receivers-com_type = 'TELEX'
*receivers-com_type = 'INT' Internet Mail !!!!
receivers-express = 'X'.
* receivers-COPY Senden: Als Kopie.
* receivers-BLIND_COPY Senden: Als geheime Kopie.
* receivers-NO_FORWARD Weiterleiten des Objektes ist verboten.
* receivers-NO_PRINT Drucken des Objektes ist verboten.
* receivers-TO_ANSWER Auf das Objekt muß geantwortet werden.
* receivers-TO_DO_EXPL Erledigen: Von allen Empfängern zu erledigen.
* receivers-TO_DO_GRP Erledigungsgruppe des Empfängers
APPEND receivers TO t_receivers.
START-OF-SELECTION.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = document_data
* PUT_IN_OUTBOX = ' '
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = t_packing_list
* OBJECT_HEADER =
* CONTENTS_BIN =
contents_txt = t_contents
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = t_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
.
* nach dem erfolgreichen versenden
* Transaktion SOST die EMail anschauen !! .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Hoffe es funktioniert,
Gruß Martin ;)