Problem in sending PDF as attachment in E-Mail
Hi All,
I have developed a program to convert the spool request as PDF file and sending it to an E-Mail address.
But when i'm opening the file, I'm getting an error in Adobe Reader.
I'm attaching the code here.
Please give me the suggestions along with example Program.
Sorry, I could not attach the program here.
Thanks and regards,
Jagan Mohan.
DATA:ig_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
ig_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : ig_pdf1 TYPE TABLE OF solisti1.
DATA: g_tab_lines LIKE sy-tabix.
DATA: ig_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
ig_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
ig_objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
ig_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
ig_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: wg_doc_chng LIKE sodocchgi1.
PERFORM convert_pdf.
PERFORM sendmail.
FORM convert_pdf .
REFRESH : ig_otf , ig_pdf_tab.
ig_otf[] = wg_otf_from_fm-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = wg_bin_fsize
TABLES
otf = ig_otf
lines = ig_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " convert_pdf
FORM sendmail .
REFRESH : ig_pdf1.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_dst = '255'
TABLES
content_in = ig_pdf_tab[]
content_out = ig_pdf1[]
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE : 'U' TO ig_reclist-rec_type,
'.....' TO ig_reclist-receiver, " move email id here
'X' TO ig_reclist-express,
'INT' TO ig_reclist-com_type.
APPEND ig_reclist.
REFRESH ig_objtxt.
CONCATENATE 'Payslip of employee -' wg_vbak-vbeln INTO ig_objtxt SEPARATED BY ' '.
APPEND ig_objtxt.
Creating the document to be sent
wg_doc_chng-obj_descr = 'Pay Slip'.
wg_doc_chng-obj_name = 'PAYSLIP'.
wg_doc_chng-obj_langu = sy-langu.
Get length of objtxt.
DESCRIBE TABLE ig_objtxt LINES g_tab_lines.
READ TABLE ig_objtxt INDEX g_tab_lines.
wg_doc_chng-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( ig_objtxt ).
Creating the entry for the compressed document
CLEAR ig_objpack-transf_bin.
ig_objpack-head_start = 1.
ig_objpack-head_num = 0.
ig_objpack-body_start = 1.
ig_objpack-body_num = g_tab_lines.
ig_objpack-doc_type = 'RAW'.
APPEND ig_objpack.
DESCRIBE TABLE ig_pdf1 LINES g_tab_lines.
g_tab_lines = g_tab_lines + 1.
ig_objhead-line = 'PAYSLIP'.
APPEND ig_objhead.
Creating the entry for the compressed attachment
ig_objpack-transf_bin = 'X'.
ig_objpack-head_start = 1.
ig_objpack-head_num = 1.
ig_objpack-body_start = 1.
ig_objpack-body_num = g_tab_lines.
ig_objpack-doc_type = 'PDF'.
ig_objpack-obj_name = 'PAYSLIP'.
ig_objpack-obj_descr = 'Pay Slip'.
ig_objpack-doc_size = g_tab_lines * 255.
APPEND ig_objpack.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wg_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = ig_objpack
object_header = ig_objhead
contents_bin = ig_pdf1
contents_txt = ig_objtxt
receivers = ig_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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
Similar Messages
-
Want to send PDF as attachement using Java Mail
HI,
I am using Java mail API for sending PDF as attachment. Here is my sample code
messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler("String data for PDF using iText", "text/plain" ));
I am generating String for PDF file using iTEXT but I am unable to find out mimetype for passing into DataHandler as second paramete.
Any idea?
Thanks
ShaileshDon't convert the data to String. It isn't text so
you'll damage the binary content by doing that. In
the "demos" directory of your JavaMail download
you'll find a ByteArrayDataSource class you can use
instead of a FileDataSource. Yes, this worked for me. I create the pdf in memory as as StringBuffer and I just changed the code from
messageBodyPart.setDataHandler(new DataHandler(pdf.toString(), "application/pdf"));
to
messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(pdf.toString(), "application/pdf")));
and it worked.
Thanks a lot for your help,
Dennis -
Sending PDF output attachment in e-mail to external users from BSP
Hi All,
Please gothrough the below requirement details :
Requirement Details:
Need to achieve the functionality of sending a PDF attachment of invoice to an external
e-mail address from the BSP Application.
Implementation Details:
The Print out Output determination is already done in the system. We are using SAP R/3 4.7 (620)
In the Transaction VF03 in the initial screen there is a menubar "Billing document" and underneath that menu there is a menu item called "Issue". If we click the "Issue" menu item all the output that are already proposed will be visible and we can select the printout Output determination and can issue a printout.
I had created a FM to call from BSP and that function module will take the Invoice number as input and will call the "VF03" transaction using BDC and will trigger the Sapscript Printout . I see the the sapscript in the spool after I call the Function module .
But I don't know how I can get the Spool request number for that Function module call from BSP page ????
I got struck in this approach...
If I know the Spool number after calling the function module the it's very easy to call the following FM's for sending a e-mail with the Invoice PDF attachment.
CONVERT_OTFSPOOLJOB_2_PDF
QCE1_CONVERT
SO_NEW_DOCUMENT_ATT_SEND_API1
Please let me know if anyone can help me in this ...
Please reply ASAP.
Thanks,
GreetsonCheck out these weblogs.
/people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
Regards
Raja -
Hello,
I try to send pdf file as attachments file to mail with XI.
I use with this blog
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816
My problems is:
1. to all mails that I send have another e file Untiteld.doc, how I can avoid this file?
2. When I received the pdf file I not succeed to open it I received the message:
Adobe reader could not open 'elad.pdf' because it is either not supported
File type or because the file has been damaged (for example, it was sent as an
Email attachment and wasn't correctly decoded)
Regards
Elad Peleghi
ref this
Receiver Mail Adapter message with PDF attachment
PDF attachment in mail adapter
File adapter with attachment to mail
File with attachment to mail scenario
File To Mail Scenario With An Attachment -
Sap adobeform sending pdf as attachment with specific name
Hi Experts,
Need your help in solving my problem !!
My requirement is to send adobe form as mail attachment in PDF format, Which I am able to do.
My Problem is PDF attachment should be generated with specific name.
For example my scenario (below given screen shot),
When i click on submit by email button, PDF will be attached to my mail,
with some random name such as "d4811f8_45171.pdf" Instead it should be generated with
fixed name such as "new_attach.pdf" or dynamic name using user name such as
"Vishwa_attachment.pdf".
Kindly help to achieve my needs.
Any help will be greatly appreciated and rewarded.
Thanks in advance,
Regards,
VishwaHi Naveen,
please read through my query again, I should generate pdf when I click on "submit by email button".
I am not using any function for conversion it will happen automatically.
thanks,
Vishwa -
Service command in Preview.app - Send PDF as attachment doesn't work
I have used the following workflow for month on all my three macs.
I open up a PDF file in Preview and select "eMail PDF as attachment" from the Edit menu at the top of the screen. This will attach the current viewed PDF file to a new mail message.
I guess after updating to 10.7.2 somehow it stopped working on MacBook Pro and iMac. My Mac mini is fine.
When I do use this command I get two error messages. Service not available. Can't attach PDF to mail. Import failed. Something like that.
Does anyone know how to fix that? I repaired permissions and did all that kind of stuff.
Thanks in advance!Would it be possible, please, for someone who has/had this issue to send me the com.apple.ServicesMenu.Services.plist files from ~/Library/Containers/com.apple.Preview/Data/Library/Preferences and from ~/Library/Preferences?
Thank you. -
Not Able to send pdf as attachment through email
Hi,
I am trying to send the generated pdf as attachment throught email and for the same i am referring to this blog
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417100)ID1409662650DB01562818410448928630End?blog=/pub/wlg/8551
but when i am trying to send the mail using the method given in this blog , i am getting this error
com.sap.tc.adobe.pdfobject.core.PDFObjectRuntimeException: Processing exception during a "MergeData" operation. Request start time: Fri Dec 11 18:05:24 IST 2009 com.adobe.ProcessingException: PDF is not interactive. Data can only be imported into interactive forms. Exception Stack Trace: com.adobe.ProcessingException: PDF is not interactive
and at the backend i am getting the error as
#com.sun.mail.smtp.SMTPSendFailedException: 501 Bad address syntax
Can any one please help me out with a solution ?? Any suggestions are welcomed
Thanks a lot in advanceHi,
Thanks for your reply , but i cannot set the enabled property of the form as true as we are not using the licensed version of the live cycle designer . But if i try the example step by step then even by setting the enabled property as false , the pdf is generated and sent through the email and when i am trying to do the same thing in one of my applications its not working . The pdf is generated but as soon as i click on the button send mail the above told error is displayed .
There needs to be some other explaination for the error -
Problem while sending excel as attachment
Hi,
I am trying to send excel as attachment through an email.
I am using the fm: SO_DOCUMENT_SEND_API1
In english, I am able to get the data properly. However, when I try to send the same in Chinese, I am getting junk characters in excel file.
Could you please help me out to solve my issue.
I am clueless, why only for chinese, I am getting the issue.
Thanks,
SandeepHi Rushi,
In this FM, I am unable to find the parameter for code page. Could you please help me how exactly I can use this code page?
Thanks,
Sandeep -
Problems with sending PDF form
I am unable to send my PDF form through Microsoft Outlook mail. The error message states there I have the wrong Server name?
How exactly are you sending that document?
What do you have set in Adobe Reader | Edit | Preferences | Email accounts ? -
Opening PDF files attached to e-mails
Hi there
I experience problems opening pdf attachements to e-mails. I have an error message telling me that the file is damaged and cannot be open.
Nevertheless I can read the exact same attachment from mail on my iPad, I have that problem with my Mac Book Pro only.
I use the Apple Mail software in both cases.
This is recent, no new software installed, and Adobe Reader is up to date on both devices.
Any hint? I'm getting fed up about these Apple specific issues, what a loss of time I've never experienced such things with PCs.
EricDid you find a solution to this issue? I am facing the same problem. It was fine before, suddenly it says that all files are damaged and cannot be opened.
Thanks so much!
Krystel -
Can't open a pdf file attachement to e-mail
I canot open an e-mail pdf file attachment..I get a message
You have chosen to open Invoice---pdf
which is: Firefox HTML Document (479kB)
What should Thunderbird do with this file?
Open with Firefox (default)
I do all of the above but nothing happens and I keep getting the same message over andf over again??
Please advise what I should do
ThanksdThanks. I disabled Protected Mode, and I was able to open the pdf attachment. Just to make sure, I enabled it and then disabled it again, and when I tried to open the attachment, it did as before – Adobe Reader (Not Responding) and Internal Error message. Tried it several more times, (enable and then disable Protected Mode) and each time, Adobe Reader wouldn’t launch (Not Responding, Internal Error).
Morris Davidson -
Sending an Excel Attachment in E-mail, where linesize 255 characters
Hi,
I have a requirement where I need to send an Excel attachment of around 150 columns and the line-size is around 2000 characters.
I was planning to use SO_DOCUMENT_SEND_API1.
But, it appears that because of the restriction of 255 characters as SOLISTI1 structure has the field size of 255 characters.
Please note, I cannot use any of the OLE or foreground Excel functions, as the job runs in the background.
Please let me know if you have any solutions or work around.
Hoiping to hear from all of the experts out there.
Regards,
Anitry to use the following classes :
send_request TYPE REF TO cl_bcs,
document TYPE REF TO cl_document_bcs,
conlengths TYPE so_obj_len,
html TYPE STANDARD TABLE OF w3html,
sender_id TYPE REF TO if_sender_bcs,
recipient TYPE REF TO if_recipient_bcs,
sent_to_all TYPE os_boolean,
bcs_exception TYPE REF TO cx_bcs,
bcs_message TYPE string. -
Send a file attached to a mail send with sendmail
Hello,
I'd like to send a report with a short mail to a mailing list. This task will be done every day by executing a ksh script.
May I do it with sendmail ? how ?
Is there another way to do it ?
Thanks for your help.
NcgSorry,
question already posted on kernel Forum: "Command line mail - attachment" -
Problem in sending pdf attachment
hi all
i am facing a problem when i am sending a pdf attachment in mail... It is showing an errror that the file is not decode properly as it is an email attachment. The below code works fine for other file types. please help meFUNCTION ZMAIL_READ.
*"*"Local Interface:
*" IMPORTING
*" VALUE(SUBJECT) TYPE SO_OBJ_DES
*" VALUE(TEXT) TYPE STRING
*" VALUE(SENDER) TYPE ADR6-SMTP_ADDR
*" VALUE(RECEIVER) TYPE ADR6-SMTP_ADDR
*" VALUE(ATTACHMENTS) TYPE Z_T_XATTACH OPTIONAL
*" EXPORTING
*" VALUE(MESSAGE) TYPE STRING
DATA: lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
lo_bcs_send_request TYPE REF TO cl_bcs,
l_send type ADR6-SMTP_ADDR ,
l_rec type ADR6-SMTP_ADDR .
data: it_text type table of soli,
wa_text type soli.
DATA: lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
DATA: lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
DATA: lv_recipient_uid TYPE uname,
lv_recipient_mail TYPE adr6-smtp_addr.
data: lo_message type ref to cx_send_req_bcs value is initial,
text_val type string.
data: it_userlist type table of BAPIUSNAME,
wa_userlist type BAPIUSNAME.
data: it_selection_range type table of BAPIUSSRGE,
wa_selection_range type BAPIUSSRGE.
data: wa_attachment TYPE zxattach,
attachment_sub type SO_OBJ_DES.
DATA: xstr type xstring,
str TYPE string,
str1 type string,
it_str2 type table of soli,
wa_STR2 TYPE SOLI,
DATA: LOC_CONV TYPE REF TO CL_ABAP_CONV_IN_CE,
wa_soli type soli,
it_soli type table of soli,
it1_solix type solix_tab.
data result TYPE boolean.
data: i_ext(10) type c,
i_type type soodk-objtp.
wa_text-line = text.
append wa_text to it_text.
CLASS cl_bcs DEFINITION LOAD.
try.
lo_send_request = cl_bcs=>create_persistent( ).
catch cx_send_req_bcs.
endtry.
* Message body and subject
data: lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
try.
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = it_text
i_subject = subject ).
catch cx_send_req_bcs.
catch cx_document_bcs.
catch cx_address_bcs.
endtry.
loop at attachments into wa_attachment.
attachment_sub = wa_attachment-file_name.
it_str2 = wa_attachment-attach.
loop at it_str2 into wa_str2.
str1 = wa_str2-line.
try.
CALL FUNCTION 'SSFC_BASE64_DECODE'
EXPORTING
B64DATA = str1
* B64LENG =
* B_CHECK =
IMPORTING
BINDATA = xstr.
catch cx_sy_dyn_call_illegal_type.
endtry.
try.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = xstr
APPEND_TO_TABLE = 'X'
* IMPORTING
* OUTPUT_LENGTH =
TABLES
BINARY_TAB = it1_solix
catch cx_sy_dyn_call_illegal_type.
endtry.
endloop.
try.
CALL FUNCTION 'SA_KW_RFC_FILENAME_EXT_GET'
EXPORTING
AREA = 'IWBSOLAR'
MIMETYPE = wa_attachment-type
IMPORTING
EXTENSION = i_ext
catch cx_sy_dyn_call_illegal_type.
endtry.
i_type = i_ext.
try.
lo_document->add_attachment(
EXPORTING
i_attachment_type = i_type
i_attachment_subject = attachment_sub
i_att_content_hex = it1_solix ).
CATCH cx_document_bcs.
endtry.
endloop.
try.
lo_send_request->set_document( lo_document ).
CATCH cx_send_req_bcs.
endtry.
wa_selection_range-PARAMETER = 'address'.
wa_selection_range-field = 'e_mail'.
wa_selection_range-sign = 'I'.
wa_selection_range-option = 'EQ'.
wa_selection_range-low = receiver.
append wa_selection_range to it_selection_range.
try.
CALL FUNCTION 'BAPI_USER_GETLIST'
* EXPORTING
* MAX_ROWS = 0
* WITH_USERNAME = ' '
* IMPORTING
* ROWS =
TABLES
SELECTION_RANGE = it_selection_range
USERLIST = it_userlist.
catch cx_sy_dyn_call_illegal_type.
endtry.
read table it_userlist into wa_userlist index 1.
try.
lo_sender = cl_cam_address_bcs=>create_internet_address( sender ).
lo_send_request->set_sender(
EXPORTING
i_sender = lo_sender ).
catch cx_send_req_bcs.
catch cx_document_bcs.
catch cx_address_bcs.
return.
endtry.
try.
lo_recipient = cl_sapuser_bcs=>create( wa_userlist-USERNAME ).
lo_send_request->add_recipient(
EXPORTING
i_recipient = lo_recipient ).
* i_express = 'X' ).
catch cx_send_req_bcs.
catch cx_document_bcs.
catch cx_address_bcs.
endtry.
try.
** Send email
LO_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
lo_send_request->send( EXPORTING
i_with_error_screen = ' '
RECEIVING
result = result ).
COMMIT WORK.
CATCH CX_DOCUMENT_BCS.
CATCH CX_SEND_REQ_BCS INTO lo_message.
CATCH CX_ADDRESS_BCS.
text_val = lo_message->IF_MESSAGE~GET_TEXT( ).
endtry.
if result = 'X'.
message = 'E-Mail sent'.
else.
message = 'E-Mail not sent'.
endif.
ENDFUNCTION. -
Problem in Sending PDF as mail attachment
Hello
I am calling ADOBE form and the PDF data coming from Fucntion module converting using CONVERT_XSTRING_TO_BINARY
and the binary data I am putting in Contents_hex table parameters of SO_NEW_DOCUMENT_ATT_SEND_API1
But while openign the mail attachemnet, its saying error in opening the file, it is damaged and all.
So whats actually the problem will be?can you enable a verbose trace for ADS and reproduce the issue
please see #846610
Run the Visual Administrator for your J2EE engine.
Server -> services -> Log Configurator.
Then select 'To Advanced mode' and 'Locations' tab.
Root Location -> com -> sap -> engine -> services -> webservices -> server -> runtime -> com -> adobe_adobeDocumentServices -> AdobeDocumentServices
Please change this node to 'ALL', and save the configuration.
Modify the log severity for the following location also.
Root Location -> com -> adobe
Change severity to 'All', press 'Copy severity to subtree' and save configuration.
All ADS trace will be written in DefaultTrace of server node.
/usr/sap/<SID>/<Instance>/j2ee/cluster/serverX/log/defaultTrace*.trc
After finishing the test, don't forget to change the log level back to 'default'.
Maybe you are looking for
-
hello all, i am new to web dynpro for java.i have already done an application "Creating a Web Dynpro Application Accessing ABAP Functions" this application have good document on sdn. this application is working fine . Now i got an requiremnt for crea
-
Problem in Rolling to new a log file only when it exceeds max size (Log4net library)
Hello, I am using log4net library to create log files. My requirement is roll to a new log file with name appended with timestamp only when file size exceeds max size (file name ex: log_2014_12_11_12:34:45 etc). My config is as follow <appender name
-
Steps for customization and user part for STO
Hi, I want to configure STO in our system can u give thelink or all the steps required for customization for STO and also can u give the detail for user part how to process it from PO to invocie. regards, zafar
-
How to delete Thr created functional module dynamically
Hi All, How to delete Thr created functional module dynamically Regards, Lisa Message was edited by: Lisa Roy
-
Jpeg preview for picture books or master/versions
When creating a book does Aperture use the previews as other Apple applications use or are the actual master/version "files" with the modifications used? If it is the previews I will need to regenerate the previews in a higher quality. thanks