2009 Feb 08 8:17 AM
Hi Gurus,
I have to send PDF as attachment and I am using CL_BCS for sending mail and attachments
I have tried following example code:
DATA pdf_content TYPE solix_tab.
DATA lp_pdf_size TYPE so_obj_len.
DATA pdf TYPE xstring.
DATA w_document TYPE REF TO cl_document_bcs,
pdf = 'TEST LINE'.
pdf_content = cl_document_bcs=>xstring_to_solix(
ip_xstring = pdf ).
lp_pdf_size = XSTRLEN( pdf ).
->The following method call is to create document for HTML format
w_document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = OBJTXT[]
i_length = w_length
i_subject = us_subject ).
-> Now I am trying to attach PDF
CALL METHOD W_DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE = 'PDF'
I_ATTACHMENT_SUBJECT = 'TEST.PDF'
I_ATTACHMENT_SIZE = lp_pdf_size
I_ATT_CONTENT_HEX = pdf_content[].
After trying the above piece of code I was able to send email (used all required methods of class for sending email) but when I open PDF it is giving following error...
File does not begin with '%PDF-"
Please let me know what all setting I am missing.
Thanks !!!
Naveen
2009 Feb 08 8:32 AM
check page26 of this document https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0bba346-cb84-2910-2aa9-ba1f8a1c...
code reference from above document
document = cl_document_bcs=>create_document(
i_type = 'RAW' " <--------------------------
i_text = l_mailtext
i_length = textlength
i_subject = l_subject ).
attdoctype = 'pdf'.
atttitle = 'CreateFlight'. "<------------- no extn .pdf specified
attsize = xstrlen( pdf ).
pdftab = cl_document_bcs=>xstring_to_solix(
ip_xstring = pdf ).
document->add_attachment( exporting I_ATTACHMENT_TYPE = attdoctype
I_ATTACHMENT_SUBJECT = atttitle
I_ATTACHMENT_SIZE = attsize
I_ATTACHMENT_LANGUAGE = sy-langu
I_ATT_CONTENT_HEX = pdftab ).кu03B1ятu03B9к
Edited by: kartik tarla on Feb 8, 2009 2:03 PM
2009 Feb 13 6:20 AM