Wird BCS genutzt (cl_bcs)?mamba hat geschrieben:Ich habe nun schon ne Weile gesucht, aber nichts für einen Text gefunden.
Code: Alles auswählen.
* Mail erstellen
lr_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = it_mailtext[]
i_subject = i_subject ).
CATCH cx_document_bcs INTO lr_cx_document_bcs.
* und an das Sendeobjekt hängen
CALL METHOD lr_send_request->set_document( lr_document ).
Okay für Multirelated gibt es einen eigenen Beispielreport:mamba hat geschrieben:Merci für die schnelle Antwort!
Leider gibts das Beispielprogramm bei mir nicht...
Mit der Methode cl_document_bcs=>create_from_multirelated wird ein Objekt der Klasse CL_GBT_MULTIRELATED_SERVICE übergeben.mamba hat geschrieben: CALL METHOD cl_document_bcs=>create_from_multirelated
Hier kann ich keinen Text mitgeben.
In deinem Coding sollte in etwa sowas stehen:mamba hat geschrieben:Wo finde ich das? CL_GBT_MULTIRELATED_SERVICE
Code: Alles auswählen.
call method cl_document_bcs=>create_from_multirelated
exporting
i_subject = subject
i_multirel_service = lo_mime_helper "Dies ist eine Objekt vom Typ CL_GBT...
receiving
result = lo_doc_bcs.
Code: Alles auswählen.
create object lo_mime_helper.
call method lo_mime_helper->set_main_html
exporting
content = lt_soli
filename = 'filenamehtml'
description = 'descriptionhtml'.
* bzw.
call method lo_mime_helper->set_main_text
exporting
content = lt_soli
filename = l_filename
description = 'descriptiontext'.
Code: Alles auswählen.
try.
call method cl_document_bcs=>create_from_multirelated
exporting
i_subject = subject
i_multirel_service = lo_mime_helper
receiving
result = lo_doc_bcs.
catch cx_document_bcs .
message e672(so) with 'bcs error while creating bcs_doc'.
exit.
catch cx_bcom_mime .
message e672(so) with 'mime error while creating bcs_doc'.
exit.
endtry.
*- create send_request
call method cl_bcs=>create_persistent
receiving
result = lo_bcs.
try.
call method lo_bcs->set_document
exporting
i_document = lo_doc_bcs.
catch cx_send_req_bcs .
message e672(so) with 'bcs error in set_document'.
exit.
endtry.
Code: Alles auswählen.
* HTML-Format von ASCII nach BINÄR
CLEAR: lt_soli, lt_soli[].
CLEAR: lt_solix, lt_solix[].
* MIME-Helper-Klasse aufsetzen
CREATE OBJECT lo_mime_helper.
* Hauptdokument ist leer
CALL METHOD lo_mime_helper->set_main_html
EXPORTING
content = lt_soli
filename = 'filenamehtml'
description = 'descriptionhtml'.
lt_soli[] = tripform_html[].
lt_solix[] = lt_soli[].
* BDS-Dok. erzeugen
TRY.
CALL METHOD cl_document_bcs=>create_from_multirelated
EXPORTING
i_subject = z_doc_chng-obj_descr
i_multirel_service = lo_mime_helper
* i_sensitivity = 'P' "20061214F#BB
RECEIVING
result = lo_doc_bcs.
CATCH cx_document_bcs .
MESSAGE e672(so) WITH 'bcs error while creating bcs_doc'.
EXIT.
CATCH cx_bcom_mime .
MESSAGE e672(so) WITH 'mime error while creating bcs_doc'.
EXIT.
ENDTRY.
* Attachment "Reisekostennachweis" hinzufügen
TRY.
CALL METHOD lo_doc_bcs->add_attachment
EXPORTING
i_attachment_type = 'HTM'
i_attachment_subject = z_doc_chng-obj_descr
i_attachment_size = z_doc_chng-doc_size
i_att_content_text = lt_soli
i_att_content_hex = lt_solix.
CATCH cx_document_bcs .
MESSAGE e672(so) WITH 'bcs error while creating attachment'.
ENDTRY.
* MIME-Format des BDS-Dok.
DATA: ref_mime_gen TYPE REF TO cl_sx_mime_singlepart
,mime_data TYPE mime_data.
* ref_mime_gen: evt. codepage aus smtp-knoten setzen
TRY.
CALL METHOD lo_doc_bcs->if_document_bcs~as_mime_document
EXPORTING
im_mime_generator = ref_mime_gen
RECEIVING
re_mime = mime_data.
CATCH cx_document_bcs .
MESSAGE e672(so) WITH 'bcs error while getting mime-format'.
ENDTRY.
*- create send_request
CALL METHOD cl_bcs=>create_persistent
RECEIVING
result = lo_bcs.
TRY.
CALL METHOD lo_bcs->set_document
EXPORTING
i_document = lo_doc_bcs.
CATCH cx_send_req_bcs .
MESSAGE e672(so) WITH 'bcs error in set_document'.
EXIT.
ENDTRY.
* set sender
* note: this is necessary only if you want to set the sender
* different from actual user (SY-UNAME). Otherwise sender is
* set automatically with actual user.
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD lo_bcs->set_sender
EXPORTING
i_sender = sender.
* Empfänger setzen
DATA l_addr TYPE adr6-smtp_addr.
TRY.
* Empfänger setzen
l_addr = z_e_mail.
* Create recipient Original
lo_recipient = cl_cam_address_bcs=>create_internet_address(
l_addr ).
CALL METHOD lo_bcs->add_recipient
EXPORTING
i_recipient = lo_recipient.
CATCH cx_root .
MESSAGE e672(so) WITH 'bcs error with internet recipient'.
EXIT.
ENDTRY.
* send
TRY.
* activate send immeditiately
* lo_bcs->set_send_immediately( 'X' ).
CALL METHOD lo_bcs->send.
CATCH cx_send_req_bcs .
MESSAGE e672(so) WITH 'bcs error while sending'.
EXIT.
ENDTRY.
COMMIT WORK.
Gut so, das ist der Interessante Teil:mamba hat geschrieben:Zur Sicherheit vielleicht einfach mal alles...
Code: Alles auswählen.
* MIME-Helper-Klasse aufsetzen
CREATE OBJECT lo_mime_helper.
* Hauptdokument ist leer
CALL METHOD lo_mime_helper->set_main_html
EXPORTING
content = lt_soli
filename = 'filenamehtml'
description = 'descriptionhtml'.
Code: Alles auswählen.
* MIME-Helper-Klasse aufsetzen
CREATE OBJECT lo_mime_helper.
***START neues Coding ***
DATA: ls_soli like line of lt_soli.
ls_soli = '<HTML>'.
APPEND ls_soli to lt_soli. Clear ls_soli.
ls_soli = '<HEAD>'.
APPEND ls_soli to lt_soli. Clear ls_soli.
ls_soli = '<TITLE>Mein Titel</TITLE>'.
APPEND ls_soli to lt_soli. Clear ls_soli.
ls_soli = '</HEAD>'.
APPEND ls_soli to lt_soli. Clear ls_soli.
ls_soli = '<BODY>'.
APPEND ls_soli to lt_soli. Clear ls_soli.
ls_soli = '<H1>Hello World</H1>'.
APPEND ls_soli to lt_soli. Clear ls_soli.
ls_soli = '</BODY></HTML>'.
APPEND ls_soli to lt_soli. Clear ls_soli.
*** ENDE neues Coding
* Hauptdokument nicht mehr leer
CALL METHOD lo_mime_helper->set_main_html
EXPORTING
content = lt_soli
filename = 'filenamehtml'
description = 'descriptionhtml'.
*** Aufräumen nicht vergessen
CLEAR lt_soli.
Refresh lt_soli.
bist du dir sicher? Wenn dein Coding stimmt hast du beim debuggen an der falschen Stelle geschaut:mamba hat geschrieben:So, ich habe das Programm mal debuggt.
LT_SOLI ist voll mit Daten. HTML-Coding.
Code: Alles auswählen.
* HTML-Format von ASCII nach BINÄR
**** Hier wird lt_soli gecleart.
CLEAR: lt_soli, lt_soli[].
CLEAR: lt_solix, lt_solix[].
* MIME-Helper-Klasse aufsetzen
CREATE OBJECT lo_mime_helper.
**** hier sollte mein Coding hin, lt_soli ist noch leer
* Hauptdokument ist leer
CALL METHOD lo_mime_helper->set_main_html
EXPORTING
content = lt_soli
filename = 'filenamehtml'
description = 'descriptionhtml'.
**** hier wird lt_soli erst gefüllt
lt_soli[] = tripform_html[].
lt_solix[] = lt_soli[].