Dear all,
Thanks for your help!
I meeting trouble issue:
Finance ask I that they want to send Reminder Notification to customer whose invoice will be matured.We sould send this notification before due day 3 days via SAP email service.
Requirement is
1) there are two attachments of PDF should be attached to email, one is status of account, the other is invoice.
2) should write letter in the email as email text.
It can send email from sap to internet. But,it is not problem to fix first requirement,it is not possible to write letter in the email.
How can I write letter in the email and attaching PDF at same time?
Thanks
B.R.
Can not input letter in the email
Moderators: Snowy, thx4allthefish, YuriT, Gothmog
Re: Can not input letter in the email
This question (I guess) has been answered a lot of times here. Use the search button for "mail" and "pdf".
Tuly Idiots
Because we know we are part of the problem
Because we know we are part of the problem
Re: Can not input letter in the email
Dear VLozanoVLozano wrote:This question (I guess) has been answered a lot of times here. Use the search button for "mail" and "pdf".
This issue is can not input letter in the email when print out with PDF, if I just only want to print out with PDF is no problem. However,if I want to input letter in the email and print out with PDF at same time. it can be not carried out.
Please help!
Thanks.
B.R.
Re: Can not input letter in the email
Hi,
Here is sample of code we use to do it.
Here is sample of code we use to do it.
Code: Select all
***********************Method Signature*****************************************************************
P_SUBJECT Importing Type STRING Description of an E-Mail
P_RECEIVER Importing Type AD_SMTPADR Recipient
PT_ATTA_HEX Importing Type RCF_T_ATT4MAIL_HEX Mail Attachments
P_LANGU Importing Type SPRAS Language Key
P_SENDER Importing Type AD_SMTPADR E-Mail Address
P_BODY_C Importing Type SOLI_TAB
P_BODY_X Importing Type SOLIX_TAB
P_DOC_TYPE Importing Type SO_OBJ_TP 'RAW' Code for Document Class
P_BORIDENT Importing Type BORIDENT Object Relationship Service: BOR object identifier
***************************Method*************************************************************************
METHOD send_email_message.
DATA: lo_exception TYPE REF TO cx_root.
DATA: lo_bcs_send_request TYPE REF TO cl_bcs,
lo_bcs_document TYPE REF TO cl_document_bcs,
lo_bcs_recipient TYPE REF TO if_recipient_bcs.
DATA: lo_sender TYPE REF TO cl_sapuser_bcs.
DATA l_subject TYPE so_obj_des.
DATA: lt_hrrcf_att_table_hex TYPE solix_tab.
DATA: ls_atta_hex LIKE LINE OF pt_atta_hex,
l_err_text TYPE string,
l_sent_to_all TYPE os_boolean.
***********************************************************************
* Define Subject
l_subject = p_subject.
***********************************************************************
* Create persistent send request
TRY.
lo_bcs_send_request = cl_bcs=>create_persistent( ).
CATCH cx_send_req_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
************************************************************************
* Add Body of the document
TRY.
IF NOT ( p_body_c IS INITIAL OR p_body_x IS INITIAL ).
RAISE body_c_or_body_x.
ENDIF.
IF p_body_c IS SUPPLIED AND NOT p_body_c IS INITIAL.
lo_bcs_document = cl_document_bcs=>create_document(
i_type = p_doc_type
i_text = p_body_c
i_subject = l_subject
i_language = p_langu ).
ENDIF.
IF p_body_x IS SUPPLIED AND NOT p_body_x IS INITIAL.
lo_bcs_document = cl_document_bcs=>create_document(
i_type = p_doc_type
i_hex = p_body_x
i_subject = l_subject
i_language = p_langu ).
ENDIF.
CATCH cx_document_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
************************************************************************
* add binary attachments
IF pt_atta_hex IS NOT INITIAL.
LOOP AT pt_atta_hex INTO ls_atta_hex.
TRY.
* convert extension to upper-case, so BCS identifies it correctly
SET LOCALE LANGUAGE sy-langu.
TRANSLATE ls_atta_hex-extension TO UPPER CASE.
* convert Xstring to table
lt_hrrcf_att_table_hex = cl_document_bcs=>xstring_to_solix(
ip_xstring = ls_atta_hex-content ).
* add attachment
CALL METHOD lo_bcs_document->add_attachment
EXPORTING
i_attachment_type = ls_atta_hex-extension
i_attachment_subject = ls_atta_hex-name
i_att_content_hex = lt_hrrcf_att_table_hex
EXCEPTIONS
OTHERS = 1.
CATCH cx_document_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
ENDLOOP.
ENDIF.
* Add document to send request
TRY.
CALL METHOD
lo_bcs_send_request->set_document( lo_bcs_document ).
CATCH cx_send_req_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
* Create recipient ******************************************************************
TRY.
TRY.
lo_bcs_recipient = cl_cam_address_bcs=>create_internet_address( p_receiver ).
CATCH cx_address_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
* Add recipient with its respective attributes to send request
CALL METHOD lo_bcs_send_request->add_recipient
EXPORTING
i_recipient = lo_bcs_recipient
i_express = 'X'.
CATCH cx_send_req_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
TRY.
* Get sender object ****************************************************************
lo_sender = cl_sapuser_bcs=>create( 'MAILADM' ).
* Add sender
CALL METHOD lo_bcs_send_request->set_sender
EXPORTING
i_sender = lo_sender.
CATCH cx_address_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
CATCH cx_send_req_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
* Set attributes on send request
TRY.
CALL METHOD
lo_bcs_send_request->set_status_attributes
EXPORTING
i_requested_status = 'A'.
CATCH cx_send_req_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
************************************************************************
* Send document
TRY.
* Attach the outgoing document to the Object
IF p_borident IS NOT INITIAL.
lo_bcs_send_request->create_link( p_borident ).
ENDIF.
* set send immediately flag
lo_bcs_send_request->set_send_immediately( 'X' ).
lo_bcs_send_request->send(
RECEIVING
result = l_sent_to_all ).
COMMIT WORK.
IF l_sent_to_all NE c_true.
MESSAGE 'Mail failed' TYPE 'E'. "#EC NOTEXT
ENDIF.
CATCH cx_send_req_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
CATCH cx_bcs INTO lo_exception.
l_err_text = lo_exception->get_text( ).
MESSAGE l_err_text TYPE c_error_msg.
ENDTRY.
ENDMETHOD.
Kind Regards,
Ron Johns.
The older I get the better I was.
Ron Johns.
The older I get the better I was.