2012 Jun 22 10:19 AM
Hi,
I'm trying to embed a PDF file in a e-mail body, but I don't know if it's possible, my code is this,
thanx a lot.
DATA:
t_objbin TYPE STANDARD TABLE OF solisti1, " Attachment data
t_objtxt TYPE STANDARD TABLE OF solisti1, " Message body
t_objpack TYPE STANDARD TABLE OF sopcklsti1, " Packing list
t_reclist TYPE STANDARD TABLE OF somlreci1, " Receipient list
t_objhead TYPE STANDARD TABLE OF solisti1. " Header
DATA: wa_docdata TYPE sodocchgi1, " Document data
wa_objtxt TYPE solisti1, " Message body
wa_objbin TYPE solisti1, " Attachment data
wa_objpack TYPE sopcklsti1, " Packing list
wa_reclist TYPE somlreci1. " Receipient list
DATA: w_tab_lines TYPE i. " Table lines
* Selection Screen
PARAMETERS: p_email TYPE char120 obligatory
VISIBLE LENGTH 40
LOWER CASE.
* Start-of-selection
START-OF-SELECTION.
* Creating message
PERFORM create_message.
* Sending Message
PERFORM send_message.
*&---------------------------------------------------------------------*
*& Form create_message
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM create_message .
**1 Title, Description & Body
PERFORM create_title_desc_body.
**2 Receivers
PERFORM fill_receivers.
ENDFORM. " create_message
*&---------------------------------------------------------------------*
*& Form CREATE_TITLE_DESC_BODY
*&---------------------------------------------------------------------*
* Title, Description and body
*----------------------------------------------------------------------*
FORM create_title_desc_body.
*...Title
wa_docdata-obj_name = 'Email notification'.
*...Description
wa_docdata-obj_descr = 'Email body in HTML'.
*...Message Body in HMTL
wa_objtxt-line = '<html><body style="background-color:#FFE4C4;">'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = '<p> List of Test materials </p>'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = '<object'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = 'type="application/pdf"'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = 'data="T:\Documents and Settings\76954202\Escritorio\1107_Q715832A.pdf"'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = 'style="width: 1000px; height: 1000px;" >'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = 'ERROR (no puede mostrarse el objeto)'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = '</object>'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = '</body> </html> '.
APPEND wa_objtxt TO t_objtxt.
* Document data
DESCRIBE TABLE t_objtxt LINES w_tab_lines.
READ TABLE t_objtxt INTO wa_objtxt INDEX w_tab_lines.
wa_docdata-doc_size =
( w_tab_lines - 1 ) * 255 + STRLEN( wa_objtxt ).
* Packing data
CLEAR wa_objpack-transf_bin.
wa_objpack-head_start = 1.
wa_objpack-head_num = 0.
wa_objpack-body_start = 1.
wa_objpack-body_num = w_tab_lines.
* we will pass the HTML, since we have created the message
* body in the HTML
wa_objpack-doc_type = 'HTML'.
APPEND wa_objpack TO t_objpack.
ENDFORM. " CREATE_TITLE_DESC_BODY
*&---------------------------------------------------------------------*
*& Form fill_receivers
*&---------------------------------------------------------------------*
* Filling up the Receivers
*----------------------------------------------------------------------*
FORM fill_receivers .
wa_reclist-receiver = p_email.
wa_reclist-rec_type = 'U'.
APPEND wa_reclist TO t_reclist.
CLEAR wa_reclist.
ENDFORM. " fill_receivers
*&---------------------------------------------------------------------*
*& Form send_message
*&---------------------------------------------------------------------*
* Sending Mail
*----------------------------------------------------------------------*
FORM send_message .
* Send Message to external Internet ID
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel.6.10
TABLES
packing_list = t_objpack
object_header = t_objhead
contents_txt = t_objtxt
receivers = t_reclist
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.
IF sy-subrc NE 0.
WRITE: 'Sending Failed'.
ELSE.
WRITE: 'Sending Successful'.
ENDIF.
ENDFORM. " send_message
Hi,
I'm trying to embed a PDF file in a e-mail body, but I don't know if it's possible, my code is this,
thanx a lot.
DATA:
t_objbin TYPE STANDARD TABLE OF solisti1, " Attachment data
t_objtxt TYPE STANDARD TABLE OF solisti1, " Message body
t_objpack TYPE STANDARD TABLE OF sopcklsti1, " Packing list
t_reclist TYPE STANDARD TABLE OF somlreci1, " Receipient list
t_objhead TYPE STANDARD TABLE OF solisti1. " Header
DATA: wa_docdata TYPE sodocchgi1, " Document data
wa_objtxt TYPE solisti1, " Message body
wa_objbin TYPE solisti1, " Attachment data
wa_objpack TYPE sopcklsti1, " Packing list
wa_reclist TYPE somlreci1. " Receipient list
DATA: w_tab_lines TYPE i. " Table lines
* Selection Screen
PARAMETERS: p_email TYPE char120 obligatory
VISIBLE LENGTH 40
LOWER CASE.
* Start-of-selection
START-OF-SELECTION.
* Creating message
PERFORM create_message.
* Sending Message
PERFORM send_message.
*&---------------------------------------------------------------------*
*& Form create_message
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM create_message .
**1 Title, Description & Body
PERFORM create_title_desc_body.
**2 Receivers
PERFORM fill_receivers.
ENDFORM. " create_message
*&---------------------------------------------------------------------*
*& Form CREATE_TITLE_DESC_BODY
*&---------------------------------------------------------------------*
* Title, Description and body
*----------------------------------------------------------------------*
FORM create_title_desc_body.
*...Title
wa_docdata-obj_name = 'Email notification'.
*...Description
wa_docdata-obj_descr = 'Email body in HTML'.
*...Message Body in HMTL
wa_objtxt-line = '<html><body style="background-color:#FFE4C4;">'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = '<p> List of Test materials </p>'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = '<object'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = 'type="application/pdf"'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = 'data="T:\Documents and Settings\76954202\Escritorio\1107_Q715832A.pdf"'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = 'style="width: 1000px; height: 1000px;" >'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = 'ERROR (no puede mostrarse el objeto)'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = '</object>'.
APPEND wa_objtxt TO t_objtxt.
wa_objtxt-line = '</body> </html> '.
APPEND wa_objtxt TO t_objtxt.
* Document data
DESCRIBE TABLE t_objtxt LINES w_tab_lines.
READ TABLE t_objtxt INTO wa_objtxt INDEX w_tab_lines.
wa_docdata-doc_size =
( w_tab_lines - 1 ) * 255 + STRLEN( wa_objtxt ).
* Packing data
CLEAR wa_objpack-transf_bin.
wa_objpack-head_start = 1.
wa_objpack-head_num = 0.
wa_objpack-body_start = 1.
wa_objpack-body_num = w_tab_lines.
* we will pass the HTML, since we have created the message
* body in the HTML
wa_objpack-doc_type = 'HTML'.
APPEND wa_objpack TO t_objpack.
ENDFORM. " CREATE_TITLE_DESC_BODY
*&---------------------------------------------------------------------*
*& Form fill_receivers
*&---------------------------------------------------------------------*
* Filling up the Receivers
*----------------------------------------------------------------------*
FORM fill_receivers .
wa_reclist-receiver = p_email.
wa_reclist-rec_type = 'U'.
APPEND wa_reclist TO t_reclist.
CLEAR wa_reclist.
ENDFORM. " fill_receivers
*&---------------------------------------------------------------------*
*& Form send_message
*&---------------------------------------------------------------------*
* Sending Mail
*----------------------------------------------------------------------*
FORM send_message .
* Send Message to external Internet ID
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel.6.10
TABLES
packing_list = t_objpack
object_header = t_objhead
contents_txt = t_objtxt
receivers = t_reclist
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.
IF sy-subrc NE 0.
WRITE: 'Sending Failed'.
ELSE.
WRITE: 'Sending Successful'.
ENDIF.
ENDFORM. " send_message
2012 Jun 22 1:07 PM
Hi Helios,
Can you try to add the PDF as an attachment and then use <object> tag to display this.
Use the attachment name in 'data'.
Thanks,
Shambu
2012 Jun 22 2:49 PM
Hi Helios,
I never saw an email with pdf embedded in the body. Mails are plain text, HTML or some kind of Microsoft format. None of them can have a portable document file PDF in the body.
Procedures to attach PDF files to CL_BCS mails have been discussed here over and over again. Also, everybody knows that SO_NEW_DOCUMENT_ATT_SEND_API1 is an outdated, unsupported function module.
Regards
Clemens
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |