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

Outlook.Application Object

Former Member
0 Likes
1,027

Hello Experts,

i am using the 'Outlook.Application' object to create a new outlook email item in my ABAP code. everything is fine except when i'm creating an attachment, i don't know how to attach a file to my email. My code look like this.

REPORT ztest_outlookobject .

INCLUDE ole2incl .

DATA: lr_outlook TYPE ole2_object,

lr_mi TYPE ole2_object,

lr_at TYPE ole2_object.

CREATE OBJECT lr_outlook 'Outlook.Application'.

CALL METHOD OF lr_outlook 'CreateItem' = lr_mi

EXPORTING #1 = 0.

GET PROPERTY OF lr_mi 'Attachments' = lr_at.

CALL METHOD OF lr_at 'Add' = 'C:\eraseable.xls'. "<<< the problem is here >>>

SET PROPERTY OF lr_mi 'To' = 'Bai Cil'.

SET PROPERTY OF lr_mi 'CC' = 'your@cc.address'.

SET PROPERTY OF lr_mi 'Subject' = 'Your subject'.

SET PROPERTY OF lr_mi 'Body' = 'Some text'.

CALL METHOD OF lr_mi 'Display'.

FREE OBJECT lr_outlook.

but i'm getting this error: "'C:\eraseable.xls'" cannot be changed. -

Thanks

1 REPLY 1
Read only

Former Member
0 Likes
623

thanks guys.

i found the answer. here it is.

CALL METHOD OF lr_at 'Add'

EXPORTING #1 = 'C:\eraseable.xls'.