Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error at OLE2.INVOKE_OBJ 1

Status
Not open for further replies.

ekobudy

Programmer
Jul 28, 2002
42
ID
I have program to send email with attachment, but there is error at OLE2.INVOKE_OBJ.
Here is the program :

DECLARE
OutlookApp OLE2.OBJ_TYPE;
NameSpace OLE2.OBJ_TYPE; -- documents collection
Folders OLE2.OBJ_TYPE;
MailItem OLE2.OBJ_TYPE;
MailItem2 OLE2.OBJ_TYPE;
OLEPARAM ole2.list_type;
Send OLE2.OBJ_TYPE;
Attachments OLE2.OBJ_TYPE;
Attachment_dummy OLE2.OBJ_TYPE;
v_to varchar2(100):='eko_budy@edi-indonesia.co.id';
v_cc varchar2(50);
v_body varchar2(250) := 'Attached is my weekly report =^-^= I have just learnt how to send an email with attachement through forms. This is so neat!';
v_bcc varchar2(50);
v_subject varchar2(50);

BEGIN

OutlookApp := OLE2.CREATE_OBJ('Outlook.Application');

-- Create a namespace
-- Think of this as the equivalent as the Documents Collection
OLEPARAM := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(OLEPARAM,'MAPI');
NameSpace := OLE2.INVOKE_OBJ(OutlookApp,'GetNameSpace',OLEPARAM);
OLE2.DESTROY_ARGLIST( OLEPARAM );

--Create a newMail Object
OLEPARAM := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(OLEPARAM,0);
MailItem := OLE2.INVOKE_OBJ(OutlookApp,'CreateItem',OLEPARAM);
OLE2.DESTROY_ARGLIST( OLEPARAM );

-- Show the new message box. - Dont do when mailing straight Through
-- MailItem2 := OLE2.INVOKE_OBJ(Mailitem,'Display');

ole2.set_property(MailItem,'To',v_to);
ole2.set_property(MailItem,'CC',v_cc);
ole2.set_property(MailItem,'BCC',v_bcc);
ole2.set_property(MailItem,'Subject',v_subject);
ole2.set_property(MailItem,'Body',v_body);


Attachments := OLE2.GET_OBJ_PROPERTY(MailItem,'Attachments');
--Adding an Attachment
OLEPARAM := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(OLEPARAM,'c:\temp\WeeklyReport.doc');
Attachment_dummy := OLE2.INVOKE_OBJ(Attachments,'add',OLEPARAM);
OLE2.DESTROY_ARGLIST( OLEPARAM );


Send := OLE2.INVOKE_OBJ(Mailitem,'Send');

OLE2.RELEASE_OBJ( MailItem);
OLE2.RELEASE_OBJ( NameSpace );
OLE2.RELEASE_OBJ( OutlookApp );

END;

Help me plz.
 
This code worked fine for me, except that the body of the message came across as an attachment. Do you know which INVOKE_OBJ is creating the error. Does the c:\temp\WeeklyReport.doc exist on your system?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top