0% found this document useful (0 votes)
74 views2 pages

Mail Example For Smartform Attachment

This document contains code to send an email. It creates a document object containing sample text, attaches a PDF file to it, sets the recipient addresses, sender, and sends the email, committing the transaction and displaying a success message.

Uploaded by

Jagath Jayasurya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views2 pages

Mail Example For Smartform Attachment

This document contains code to send an email. It creates a document object containing sample text, attaches a PDF file to it, sets the recipient addresses, sender, and sends the email, committing the transaction and displaying a success message.

Uploaded by

Jagath Jayasurya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

perform sendmail.

FORM send_mail .
****send mail
IF send_m IS NOT INITIAL.
DATA send_request TYPE REF TO cl_bcs.
DATA document TYPE REF TO cl_document_bcs.
DATA: size TYPE so_obj_len,
it_contents TYPE STANDARD TABLE OF solisti1,

lt_pdf_data TYPE solix_tab,


doc_data TYPE so_obj_des.
DATA recipient TYPE REF TO if_recipient_bcs.
DATA recipient1 TYPE REF TO if_recipient_bcs.
DATA sender TYPE REF TO if_sender_bcs.
DATA sent_to_all TYPE os_boolean.
DATA: receiver_to TYPE ad_smtpadr,
receiver_cc TYPE ad_smtpadr.
doc_data = 'Funds Requisition Application'.
APPEND VALUE #( line = 'sample text' ) TO it_contents .
APPEND VALUE #( line = 'Sample Text from ALIMCO ' ) TO it_contents .
send_request = cl_bcs=>create_persistent( ).

document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = it_contents
i_subject = doc_data ).

lt_pdf_data = cl_document_bcs=>xstring_to_solix( gs_form_output-pdf ).


*
* document->add_attachment( i_attachment_type = 'BIN'
* i_attachment_subject =
'FILENAME.PDF'
* i_att_content_hex =
lt_pdf_data
* ).
document->add_attachment(
i_attachment_type = 'PDF'
i_attachment_subject = 'Instal'
i_attachment_size = size
i_att_content_hex = lt_pdf_data ).

send_request->set_document( document ).

receiver_to = '[email protected]'.
receiver_cc = '[email protected]'.
IF receiver_to IS NOT INITIAL .
recipient = cl_cam_address_bcs=>create_internet_address( receiver_to ).
send_request->add_recipient( i_recipient = recipient ).
ENDIF.
IF receiver_cc IS NOT INITIAL .
recipient1 = cl_cam_address_bcs=>create_internet_address( receiver_cc ).
send_request->add_recipient( i_recipient = recipient1
i_copy = ' ' ).
ENDIF.

CALL METHOD send_request->set_sender


EXPORTING
i_sender = sender.

sent_to_all = send_request->send( i_with_error_screen = 'X' ).

COMMIT WORK.
MESSAGE 'Mail has been sent successfully' TYPE 'I'.
ENDIF.

You might also like