Application Development and Automation 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: 
Read only

Help in OLE2 Programming

Former Member
0 Likes
812

Dear gurus below is the code to open outlook but the problem is that the attachment is not added where im getting wrong please help

Also i want to add report output in the attachment how to do that.

REPORT zreport_to_email .
TYPE-POOLS ole2.

DATA: 
appoutlook TYPE ole2_object,
appitem TYPE ole2_object,
namespace TYPE ole2_object,
attachs TYPE ole2_object,

BEGIN OF itab_paths OCCURS 0,
path(255),
END OF itab_paths,
mail_index TYPE i.
CREATE OBJECT appoutlook 'outlook.application'.
CALL METHOD OF appoutlook 'GetNameSpace' = namespace
  EXPORTING #1 = 'MAPI'.
CALL METHOD OF appoutlook 'CreateItem' = appitem
  EXPORTING #1 = '0'.
GET PROPERTY OF appitem 'Attachments' = attachs.
SET PROPERTY OF appitem 'to' = 'abc @ abc. com'.
set property of appitem 'cc' = 'xyz @ zyx.com; abc @ cba.com'.
SET PROPERTY OF appitem 'Subject' = 'The first mail with OLE2'.
mail_index = 1.
LOOP AT itab_paths.
  CALL METHOD OF attachs 'Add'
    EXPORTING
    #1 = itab_paths-path
    #2 = '1'
    #3 = mail_index
    #4 = itab_paths-path.
   mail_index = mail_index + 1.
ENDLOOP.
CALL METHOD OF appitem 'Display'.
FREE: attachs, appitem, namespace, appoutlook.

Regards

Saad Nisar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
717

Hi,

I added 2 lines of code after definition of itab_paths, and it works for me:


itab_paths-path = 'd:\Downloads\sapcar.exe'.
APPEND itab_paths.

Regards,

--

Przemysław

7 REPLIES 7
Read only

Former Member
0 Likes
718

Hi,

I added 2 lines of code after definition of itab_paths, and it works for me:


itab_paths-path = 'd:\Downloads\sapcar.exe'.
APPEND itab_paths.

Regards,

--

Przemysław

Read only

0 Likes
717

can we attach another report output ?

Read only

0 Likes
717

Hi,

sure, here it is below. Please check also, if the file really is under specified location.


REPORT zreport_to_email.
TYPE-POOLS ole2.

DATA:
  appoutlook TYPE ole2_object,
  appitem TYPE ole2_object,
  namespace TYPE ole2_object,
  attachs TYPE ole2_object,

  BEGIN OF itab_paths OCCURS 0,
    path(255),
  END OF itab_paths,
  mail_index TYPE i.

*************
itab_paths-path = 'd:\Downloads\sapcar.exe'.
APPEND itab_paths.
*************

CREATE OBJECT appoutlook 'outlook.application'.
CALL METHOD OF appoutlook 'GetNameSpace' = namespace
  EXPORTING #1 = 'MAPI'.
CALL METHOD OF appoutlook 'CreateItem' = appitem
  EXPORTING #1 = '0'.
GET PROPERTY OF appitem 'Attachments' = attachs.
SET PROPERTY OF appitem 'to' = 'abc @abc.com'.
SET PROPERTY OF appitem 'cc' = 'xyz @zyx.com; abc @cba.com'.
SET PROPERTY OF appitem 'Subject' = 'The first mail with OLE2'.
mail_index = 1.
LOOP AT itab_paths.
  CALL METHOD OF attachs 'Add'
    EXPORTING
    #1 = itab_paths-path
    #2 = '1'
    #3 = mail_index
    #4 = itab_paths-path.
  mail_index = mail_index + 1.
ENDLOOP.
CALL METHOD OF appitem 'Display'.
FREE: attachs, appitem, namespace, appoutlook.

Regards,

--

Przemysław

Read only

0 Likes
717

Dear Przemysław

Thanks for your response.

now my query is that

i have a customized report zabc and its ouput is in alv.

what i want to do is that i want to run this application perform opening that report executing it and generating the output and attaching it to mail can we do this?

Read only

0 Likes
717

Hi,

yes, you can do that, but you do not need OLE to do that.

I thought, you need some files which is on customer side.

If you want to send mail from SAP, just use the SO_NEW_DOCUMENT_ATT_SEND_API1 function module.

You can also send emails with attachments. You will find a lot of examples in the web.

Regards,

--

Przemysław

Read only

0 Likes
717

im having error in INT area

im lacking to configure my SMTP

can u guide me ?

Read only

0 Likes
717

Hi,

unfortunately, this is a basis question.

Please close this thread and post new message in proper forum.

Regards,

--

Przemysław