Sending a binary attachment via email, looking for a more clean way
Hi experts.
I finally managed to send a binary attachment via email. Why "finally"? Never done before!
Also I got to manage the "not standard" .SAP file extension, because the attachment is a transaction link.
So let me explain how i did it:
take SO_NEW_DOCUMENT_ATT_SEND_API1, filling following input data:
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = st_docdata
commit_work = 'X'
TABLES
packing_list = lt_packlist
contents_hex = lt_hex
contents_txt = lt_content
receivers = lt_recv
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.
But how to fill lt_hex? Well I did not found a way to transfer text data into raw data structure (lt_hex is type SOLIX).
So, here is the trick:
fill another table, lt_bin type SOLISTI1, with attachment content (text data);
dump lt_bin content to a file on application server, having care to specify TEXT MODE and UTF-8 encoding;
now reopen the same file in BINARY MODE and transfer content to lt_hex.
Why I did not use parameter
content_bin
? Because SAP ECC 6 is unicode enabled (I think UTF-16) and file has got to be UTF-8 or ASCII. Also, packing_list for attachment must specify binary tranfer mode. And doing so each UTF-16 character (2 bytes) is split into 2 characters (1 char + 1 NUL byte). Attachment is now unusable.
What is the question? Here it is: how to fill lt_hex data directly from text (UTF-16) data, avoiding conversion errors?
Thank you in advance.
Hi Chhayank,
the problem is not the exported xls. If you have a look inside with Notepad or something like that, you will see that your leading zeros are exported correct.Excel-settings occurs this problem, it is all about how to open the document. If you use the import-assistant you will have no problems because there are options available how to handle the different columns.
Another solution might be to get familiar with ABAP2XLS-Project. I got in my mind, that there is a method implemented, that will help you solving this problem. But that is not a five minute job
~Florian
Similar Messages
-
Facing problem with the code for sending an .xls attachment via email, a field value contains leading zeros but excel automatically removes these from display i.e. (00444 with be displayed as 444).kindly guide .
Hi Chhayank,
the problem is not the exported xls. If you have a look inside with Notepad or something like that, you will see that your leading zeros are exported correct.Excel-settings occurs this problem, it is all about how to open the document. If you use the import-assistant you will have no problems because there are options available how to handle the different columns.
Another solution might be to get familiar with ABAP2XLS-Project. I got in my mind, that there is a method implemented, that will help you solving this problem. But that is not a five minute job
~Florian -
Error opening PDF file when send as attachment via email
Hi,
I searched around the forum to resolve my issue and there's alot of post that is related but i can't find any answer to my issues.
Here's the scenario :-
I try to convert the smartform to PDF and then send the PDF as an attachment via email.
After converting the smartform to PDF, i managed to download the file and view it without any problem but i can't view the PDF as an attachment. It has the following error :-
Adobe Reader could not open '4500002325.PDF' because it is either not a supported fle type or because the file has been damaged (for example, it was sent as an email and wasn't correctly decoded
The following is the snapshot of my code:-
* Determine smartform function module for invoice
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* error handling
ent_retco = sy-subrc.
PERFORM protocol_update_i.
ENDIF.
ls_control_param-getotf = 'X'.
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
zxekko = l_doc-xekko " user_settings = ' '
zxpekko = l_doc-xpekko
IMPORTING
document_output_info = l_ssfcrespd
job_output_info = l_ssfcrescl
job_output_options = l_ssfcresop
TABLES
l_xekpo = l_doc-xekpo[]
l_xekpa = l_doc-xekpa[]
l_xpekpo = l_doc-xpekpo[]
l_xeket = l_doc-xeket[]
l_xtkomv = l_doc-xtkomv[]
l_xekkn = l_doc-xekkn[]
l_xekek = l_doc-xekek[]
l_xkomk = l_xkomk
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc = 0.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = v_len_in
BIN_FILE = v_bin_file
TABLES
OTF = l_ssfcrescl-otfdata
LINES = l_pdf
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
* email subject
CONCATENATE 'Purchase order' l_doc-xekko-ebeln INTO lw_subject
SEPARATED BY space.
* RECIPIENTS
lwa_recipients-rec_type = 'U'.
lwa_recipients-express = 'X'.
SELECT adr6~smtp_addr
INTO TABLE gv_smtp_addr
FROM ekko AS ekko INNER JOIN
lfa1 AS lfa1 ON ekko~lifnr = lfa1~lifnr INNER JOIN
adr6 AS adr6 ON adr6~addrnumber = lfa1~adrnr
WHERE ekko~ebeln = l_doc-xekko-ebeln.
IF NOT gv_smtp_addr[] IS INITIAL.
LOOP AT gv_smtp_addr INTO gv_smtp_addr_line FROM 2.
lwa_recipients-receiver = gv_smtp_addr_line.
lwa_recipients-copy = ''.
APPEND lwa_recipients TO ptb_recipients.
ENDLOOP.
* Text Data
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'ST'
language = 'E'
name = 'TEST'
object = 'TEXT'
TABLES
lines = lv_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
LOOP AT lv_lines INTO lv_lines_line.
ltb_objtxt = lv_lines_line-tdline.
APPEND ltb_objtxt.
ENDLOOP.
DESCRIBE TABLE ltb_objtxt LINES lw_tab_lines.
READ TABLE ltb_objtxt INDEX lw_tab_lines.
* document data contains information for the whole message
lwa_doc_chng-obj_descr = 'ABAPlist'.
* Control Data
lwa_doc_chng-obj_name = 'TESTING'.
lwa_doc_chng-sensitivty = 'F'.
lwa_doc_chng-no_change = 'X'.
lwa_doc_chng-priority = '1'.
lwa_doc_chng-obj_prio = '1'.
lwa_doc_chng-obj_langu = sy-langu.
CLEAR ltb_objpack-transf_bin.
*Attachment
*Move the binary attachment to other internal table.
ltb_objpack-head_start = 1.
ltb_objpack-head_num = 0.
ltb_objpack-body_start = 1.
ltb_objpack-body_num = lw_tab_lines.
ltb_objpack-doc_type = 'RAW'.
APPEND ltb_objpack.
clear : lw_tab_lines.
*Get the number of lines in the Attachment (PDF FILE)
* DESCRIBE TABLE it_mess_att LINES lw_tab_lines.
DESCRIBE TABLE l_objbin lines lw_tab_lines.
ltb_objpack-transf_bin = 'X'.
ltb_objpack-head_start = 1.
ltb_objpack-head_num = 1.
ltb_objpack-body_start = 1.
ltb_objpack-body_num = lw_tab_lines.
ltb_objpack-doc_type = 'PDF'.
ltb_objpack-obj_descr = l_doc-xekko-ebeln.
ltb_objpack-doc_size = lw_tab_lines * 255.
APPEND ltb_objpack.
*Email Subject
lwa_doc_chng-obj_descr = lw_subject.
lwa_recipients-receiver = recipeint.
lwa_recipients-rec_type = 'U'.
lwa_recipients-copy = 'X'.
lwa_recipients-express = 'X'.
APPEND lwa_recipients TO ptb_recipients.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = lwa_doc_chng
COMMIT_WORK = 'X'
TABLES
packing_list = ltb_objpack
contents_bin = l_objbin
contents_txt = ltb_objtxt
receivers = ptb_recipients.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDIF.
Edited by: ~loObie on Apr 23, 2010 12:01 PM
Edited by: ~loObie on Apr 23, 2010 12:02 PMDid you send the pdf in the following format ...
2. Sending PDF as mail.
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = sy-uname.
t_receivers-rec_type = 'B'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
Quote from the Following [LINK|http://www.sap-basis-abap.com/smartforms/convert-the-smart-form-into-pdf-and-send.htm] -
To send output as a PDF attachment via email
Hi experts
I have the (smartform) output data in OTF format..and displaying it in PDF form with FM 'HR_EFI_SHOW_PDF_FORM' .
Now the requirement is <b>to send this output as a PDF attachment via email</b>.
Please help me with sample code to perform this.
Regards,
Matt.Hi,
Check this links,
/people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
Also for email:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-938c601d5db9
Refer the following link for more details:
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
Thanks,
Reward If Helpful. -
Why cant I send a vid clip via email, it just won't attach ?
Why can't I send a vid clip via email, it just won't attach ?
You could compress it by creating a zip file - right click on the file and then select 'Compress' - a zip file will be created. Although when you're compressing a single file the resulting .zip files tends only to be a litlle small than the original.
A much better alternative would be to sign up for dropbox.com - which literally puts a folder on a desktop that syncs with 'the cloud'. Then you can share your files from there (as well as have them available form any browser whereever you are!. It's super easy to use - but really useful! -
How do you send an attachment via email created on a mac
how do you send an attachment via email to another recipient who does not have a mac?
As long as you send it in a recognizable format such as a .jpeg (or .jpg) used for most photos/images or .pdf used for a lot of word processing docs, there is no problem. Also, while in the Mail window, choose "send Windows compatible". It's not who or what you create it on, it is the format you send it in.
-
I'm having a problem sending a word doc via email. I have Mac for Office 08, and I'm using Mavericks OS. When I save the document as a .doc or .docx, and send it to someone, (doesn't matter if its safari, chrome or firefox or on my yahoo or gmail accounts) they receive it as a blank document. Yet, when I open it on my Mac, it has a "word" icon and I can read it. How do I fix?
I suggest you post on the Microsoft Mac forums since it's their software you're having issues with.
http://answers.microsoft.com/en-us/mac -
How do I scan a photo to a file and then send the file as an attachment via email.
How do I scan a photo to a file and then send the file as an attachment via email.
All of this depends largely on what printer /software you have, which Email client you use and to some extent which OS you are running.
Most HP printers have HP Solution Center which is used to set up scanning,choosing where to save,etc. Once a file/photo is scanned and saved to the folder, open the folder.Select the file and at the top of the window should be the option to 'Email'.
******Clicking the Thumbs-Up button is a way to say -Thanks!.******
**Click Accept as Solution on a Reply that solves your issue to help others** -
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 -
Send CSV or table via email in daily job?
Hello,
I built a application where our employees can order meals. In case the whole application and everything crashes down, the DBA has 2 days to restore the application, database, etc...
To "survive" the 2 days I want to make a daily export of the necessary data, that the kitchen can continue its work.
Now I planned to make a view with the necessary data and export this as plain text in an email.
Is there another better possibility? Maybe create a CSV file and attach this to a email and send it via a daily job? Or is it possible to send a whole table via email?
Everything should work automatically via a job.
Thank you so much,
LisaYou could have a daily batch job run, where the job pulls the required info into a report, generates the report and sends it to required folks..: http://nzchaudhry.wordpress.com/2011/06/28/sending-report-as-email-attachment-in-oracle-apex/
Thank you,
Tony Miller
Webster, TX
There are two kinds of pedestrians -- the quick and the dead.
If this question is answered, please mark the thread as closed and assign points where earned.. -
How to generate payment advice in F110 and send it to Vendors Via Email
Dear SAP Experts
Could anybody tell me how to generate payment advice in F110 and send it to Vendors Via Email?
It would be much appreciated if someone can provide the configuration procedure, thanks so much in advance.
Cheers & Best Regards
RayHi Sama,
Thanks for your post, here I just share some of my idea.
The following step is to configure the payment advice.
In OBVU (payment methods in cpy code) I entered my payment advice form
In OBVU (payment methods in cpy code) set "Always pyt advice"
In OBVCU (payment method by country) leave the payment medium program (RFFOD__T)
For the email sending program, should develp some customized program to realize that, Thanks.
Cheers & Best Regards
Ray -
please help!!!!!! i filled out a job application using adobe reader but i cannot send the file back via email because the file is protected with a lock. how do i unlock this file to send it?!!!!!!!!!
Hi kevinv1987,
It doesn't sound like the PDF was password protected (or Adobe Reader would prompt you for a password). Instead, it sounds like that file may be marked locked by your operating system. Are you on Mac OS or Windows? In either case, here are instructions for removing the lock icon from the file:
Remove the Lock Icon from a Folder in Windows 7 (check Microsoft's website if you have a different version of Windows)
On Mac OS, select the file in the Finder, and choose File > Get Info. Then, just deselect the Lock checkbox.
Please let us know how it goes.
Best,
Sara -
Looking for the most easy way to position images on a page!?
Hi, I'm looking for the most easy way for exact position a lot of PNG images on a web page. Input appreciated!
Thanks!Basic 1-col layout with 3 evenly spaced boxes:
http://alt-web.com/TEMPLATES/Basic-1-col-fixed.html
CSS Floats and Margins tutorial -
http://alt-web.com/DEMOS/3-CSS-boxes.shtml
Float left & float right images with wrapping text
http://alt-web.com/DEMOS/CSS2-Captions-on-floated-images.shtml
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
www.alt-web.com/
www.twitter.com/altweb
www.alt-web.blogspot.com -
I've forgotten my questions confidentiality,but I can not be rest or via email due tomi sin the run way email has noticed that heen dsb hotmil and not hotmail
I've forgotten my questions confidentiality,but I can not be rest or via email due tomi sin the run way email has noticed that heen dsb hotmil and not hotmail
-
In Adobe froms - Sending PDF file as Attachment via email
I have to develop a <b>PDF form</b> and one more requirement; I have to change the mail Content (body) and the Subject line which should have attached PDF file.The (Transaction Code VA21) Has the sending the Email part. My Requirement is to <b>Change the Content (body) and the Subject</b>.
Requirement;
When customer request for the quote, quote document is created in SAP (Transaction Code VA21). Promised Price, quantity, date is communicated to customer via quote output. Customer may decide to place firm order with reference to quote.
So this form (PDF file and send via email) is used to communicate the AMAT quote to customer. The PDF file will be as a attachment in the mail. With change subject line, and content of the mail (Thanks for the Quote, Please dont reply to this mail). It also consists of applicable terms & condition of the quote.
Is it possible to handle the Content and the Subject of the mail in Program or Form layout (SFP). or it's Enhancement?
How to go about it? I tried a lot. At last am contacting you. Please.............. Let me know. Very urgent.Point will be given sooon. Tnx a lot.....
#SinivasHi,
Yes But you can use ADOBE FORMS for that... Check this link for presentation...
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c0c139d3-3eae-2910-01a1-d253f2587b0e?prtmode=navigate
Check this BLOG for sending Email through ABAP..
Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface
One more thing... You can download your data to a PDF file and send that PDF file via program...
Search this Forum for more answers.. you would get plenty out of it...
Check this thread for further information..
Sending mail with 2 attachments
Hope this would help you.
Any queries plz revert back
Good luck
Narin
Maybe you are looking for
-
Mail rejecting outbound mail, gives error message
Apple mail is all of a sudden rejecting outbound mail. It leaves this Error message: "This message could not be delivered and will remain in your Outbox until it can be delivered." "The sender address [email protected] was rejected by the server." At
-
Free Goods not determined, neither in STO nor in OBD
We are using IS-Retail and ECC 6.0 We are trying to deliver Free Goods through Stock Transport Order. But free good article is not getting determined, neither in Stock Transport Order nor in Outbound Delivery. We created Free Goods condition both for
-
Hi, First I have downloaded the latest video (and capture) driver for this card. Have read the manuel, so in Nvidea Center I have set 'Video out' out witch is default off. I have a blue screen on my tv when i set 'desktop on external monitor' in scre
-
Hello! I have a problem with OwnCloud. I have installed it form AUR, done everything recommended in .install: Add the following lines into /etc/httpd/conf/httpd.conf: Include /etc/httpd/conf/extra/owncloud.conf LoadModule php5_module modules/libphp5.
-
HT203164 CD will play on computer but not in car CD player - what did I do wrong?
I burned a CD playlist to a blank CD and will play on the computer and a home CD player, but it won't play in my car CD player - did I do something wrong? Waht do I need to change when I burn another CD?