‎2007 Aug 10 4:54 PM
I am looking for code example on how to send email using HTML format.
Regards,
Daniel Cantin
‎2007 Aug 10 8:53 PM
Hi,
I have develop this code to send multiple HTML attachments using CL_BCS class
Form f_send_html_mail.
data: send_request type ref to cl_bcs.
data: document type ref to cl_document_bcs.
data: sender type ref to cl_sapuser_bcs.
data: recipient type ref to if_recipient_bcs.
data: exception_info type ref to if_os_exception_info,
bcs_exception type ref to cx_document_bcs.
data i_attachment_size type sood-objlen.
data v_status type bcs_stml.
data v_request_status type bcs_rqst.
data : v_desc like sopcklsti1-obj_descr.
concatenate 'Doc-' pdocno into v_desc.
condense v_desc no-gaps.
submit yttcr0001 exporting list to memory
with p_docno = pdocno
and return.
call function 'LIST_FROM_MEMORY'
tables
listobject = report_list
exceptions
not_found = 1
others = 2.
call function 'WWW_HTML_FROM_LISTOBJECT'
exporting
template_name = 'WEBREPORTING_REPORT'
tables
html = report_html
listobject = report_list.
describe table objbin lines tab_lines.
v_lines = tab_lines + 1.
loop at report_html.
move report_html to it_attach1.
append it_attach1.
endloop.
send_request = cl_bcs=>create_persistent( ).
try.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = it_content[]
i_subject = subject ).
if not attach_name1 is initial.
call method document->add_attachment
exporting
i_attachment_type = attach_ext1
i_attachment_subject = attach_name1
i_att_content_text = it_attach1[].
endif.
"<<< if you want multiple attachment then use this
if not attach_name2 is initial.
call method document->add_attachment
exporting
i_attachment_type = attach_ext2
i_attachment_subject = attach_name2
i_att_content_text = it_attach2[].
endif.
call method send_request->set_document( document ).
sender = cl_sapuser_bcs=>create( sy-uname ).
call method send_request->set_sender
exporting
i_sender = sender.
loop at it_recipient.
translate it_recipient-smtp_addr to lower case.
recipient = cl_cam_address_bcs=>create_internet_address( it_recipient-smtp_addr ).
call method send_request->add_recipient
exporting
i_recipient = recipient
i_express = ' '
i_copy = ' '
i_blind_copy = ' '
i_no_forward = ' '.
endloop.
move : 'E' to v_request_status.
v_status = v_request_status.
call method send_request->set_status_attributes
exporting
i_requested_status = v_request_status
i_status_mail = v_status.
call method send_request->send( ).
commit work.
catch cx_document_bcs into bcs_exception.
endtry.
endform.
aRs
‎2007 Aug 11 12:28 AM
Hi Dan,
check out this <a href="/people/thomas.jung3/blog/2005/01/05/develop-a-web-service-that-sends-an-email--in-abap log</a> from Thomas Jung.
It goes very well through how to send an email from ABAP using the BCS Classes.
I can't get onto my customers' system at the moment, but I am pretty sure that the document type for HTML email is '<b>HTM</b>' instead of '<b>RAW</b>'.
Cheers
Graham