Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

OLE2 Outlook attachment without local system

ram_sapsolution
Explorer
0 Kudos

Hi Friends,

Download function works successfully.

Currently OLE2 automation tool processing an excel file and attached from local system to outlook and sending customers and download file in local system as well.

Application Server function

No issue - A final data is placing in application server successfully

but find Issue to attach file in outlook: fails

The same OLE2 formatted file to be attached in outlook and to be sent customer without picking file from local system cause This function to run in background in this case we can’t pick file from local system.

10 REPLIES 10

Sandra_Rossi
Active Contributor
0 Kudos

Do you really need to automate Outlook? Don't you just want to create an email? (search email, attachment and BCS in the forum)

NB: when running ABAP in background, you can't access any user's laptop.

ram_sapsolution
Explorer
0 Kudos

Hi Rossi,

Already an outlook attachment is working fine for download function.

but need separate outlook attachment which is same as download data and need to copy the same excel sheet from download function and to be attached and sent customer via outlook application.

1. A radio button works for presentation server and sending mail to customers in download function.,

2. Another radio button works for application server and mail to be sent customer.

Conclusion: To copy download excel file to another excel file and to attach in outlook. it shouldn't be local path when copying file.

abo
Active Contributor

There is a complete example that does just that.

It requires abap2xlsx but it could be adapted to work without that

Sandra_Rossi
Active Contributor
0 Kudos

So you can keep the OLE code which works in dialog, and create another solution without OLE stuff in background, right?

ram_sapsolution
Explorer
0 Kudos

HI Rossi,

OLE2 code for downloading excel file in local system.

GET PROPERTY OF w_excel 'ActiveWorkbook' = w_workbook.
CALL METHOD OF
w_workbook
'SAVEAS'
EXPORTING
#1 = p_file.

Now i have to copy w_workbook to another excel to attach outlook.applicaiton cause which is formatted excel where it contains colors other stuff,

My program is going to run in background job in scheduling So which can not pick file from p_file or local system.

Sandra_Rossi
Active Contributor
0 Kudos

So you use OLE to tell Excel to create a workbook file. OLE can't run in background as I said. Instead, use abap2xlsx or a lightweight solution as Andrea mentioned.

ram_sapsolution
Explorer
0 Kudos

you mean OLE can not run in background job which means it requires to create application outlook & excel from local system. am i correct?

Sandra_Rossi
Active Contributor
0 Kudos

I don't know what means "requires to create application outlook & excel from local system", but I guess you understood what I said.

ram_sapsolution
Explorer
0 Kudos

Hi Rossi,

I already having an excel sheet data which is manipulated/formatted with colours & other stuff by OLE2 Concept and works for downloading in local system.

Now i require the same excel to copy and attach to send customers for other requirement before downloading in local system.

But my requirement has to run in background job to send mail with attachment to customers.

In this case, i can't use frontend to pick the same excel file.

i think below concepts works to convert ALV internal table data to excel sheet attachment in sending mail from the spool list.

It requires abap2xlsx but it could be adapted to work without that

Sandra_Rossi
Active Contributor

Just to clarify, if you install abap2xlsx in your system, it takes 5 lines of code to generate a workbook with one worksheet containing "hello world", that you can then attach to an email.

Adding colors and so on is easy with abap2xlsx. Moreover abap2xlsx has a template feature which allows reusing an existing Excel workbook that you fill with data.