Skip to Content
0
Former Member
Dec 11, 2006 at 07:16 AM

Outlook.Application Object

404 Views

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