Peterwantshelp
IS-IT--Management
I use following package to send mails via word. It works very good since 1998 but now we installed a win2000 with office 2000 and i get oracle error 305500. Is there anabody who give me some help ?
The Mailx package contains three procedures:
1. Procedure Mailx.logon( profile IN VARCHAR2 DEFAULT NULL);
-----------
Use this procedure to logon to the MS Exchange mail
client. The procedure takes a character argument which specifies the
Exchange Profile to use for logon. Passing a NULL argument
to the logon procedure brings up a dialog box that asks you
to choose a profile from a list of valid profiles or create a new one
if it does not exist.
2. Procedure Mailx.send(
----------
Recipient IN VARCHAR2,
Subject IN VARCHAR2 DEFAULT NULL,
Text IN VARCHAR2 DEFAULT NULL,
Attachment IN VARCHAR2 DEFAULT NULL );
This is the procedure that actually sends the message and
attachments, if any, to the recipient. The recipient may be specified directly
as a valid email address or as
an alias defined in the address book. If the message is intended for a fax recipient,
a valid alias must be used
that is defined as a fax address in the address book.
3. Procedure Mailx.logoff;
------------
This procedure closes the Exchange session and deallocates
the resources used by the OLE automation objects.
Sample Application:
-------------------------
1. Create the Mailx Package using the following two Program
Units:
(a) Mailx Package Spec
(b) Mailx Package Body
Mailx Package Spec:
-------------------
PACKAGE Mailx IS session OLE2.OBJ_TYPE; /* OLE object handle */
args OLE2.LIST_TYPE; /* handle to OLE argument list */
PROCEDURE logon( Profile IN VARCHAR2 DEFAULT NULL ); PROCEDURE logoff;
PROCEDURE send( Recp IN VARCHAR2, Subject IN VARCHAR2,
Text IN VARCHAR2,
Attch IN VARCHAR2 );
END;
Mailx Package Body:
------------------
PACKAGE BODY Mailx IS
session_outbox OLE2.OBJ_TYPE;
session_outbox_messages OLE2.OBJ_TYPE;
message1 OLE2.OBJ_TYPE;
msg_recp OLE2.OBJ_TYPE;
recipient OLE2.OBJ_TYPE;
msg_attch OLE2.OBJ_TYPE;
attachment OLE2.OBJ_TYPE;
PROCEDURE logon( Profile IN VARCHAR2 DEFAULT NULL ) IS
BEGIN
session := OLE2.CREATE_OBJ('mapi.session'); /* create the session object */
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, Profile); /* Specify a valid profile name */
OLE2.INVOKE(session, 'Logon', args); /* to avoid the logon dialog box */
OLE2.DESTROY_ARGLIST(args);
END;
PROCEDURE logoff IS
BEGIN
OLE2.INVOKE(session, 'Logoff'); /* Logoff the session and deallocate the */
/* resources for all the OLE objects */
OLE2.RELEASE_OBJ(session);
OLE2.RELEASE_OBJ(session_outbox);
OLE2.RELEASE_OBJ(session_outbox_messages);
OLE2.RELEASE_OBJ(message1);
OLE2.RELEASE_OBJ(msg_recp);
OLE2.RELEASE_OBJ(recipient);
OLE2.RELEASE_OBJ(msg_attch);
OLE2.RELEASE_OBJ(attachment);
END;
PROCEDURE send( Recp IN VARCHAR2,
Subject IN VARCHAR2,
Text IN VARCHAR2,
Attch IN VARCHAR2 ) IS
BEGIN
/* Add a new object message1 to the outbox */
session_outbox := OLE2.GET_OBJ_PROPERTY(session, 'outbox');
session_outbox_messages := OLE2.GET_OBJ_PROPERTY(session_outbox, 'messages');
message1 := OLE2.INVOKE_OBJ(session_outbox_messages, 'Add');
OLE2.SET_PROPERTY(message1, 'subject', Subject);
OLE2.SET_PROPERTY(message1, 'text', Text);
/* Add a recipient object to the message1.Recipients collection */
msg_recp := OLE2.GET_OBJ_PROPERTY(message1, 'Recipients');
recipient := OLE2.INVOKE_OBJ(msg_recp, 'add') ;
OLE2.SET_PROPERTY(recipient, 'name', Recp);
OLE2.SET_PROPERTY(recipient, 'type', 1);
OLE2.INVOKE(recipient, 'resolve');
/* Add an attachment object to the message1.Attachments collection */
msg_attch := OLE2.GET_OBJ_PROPERTY(message1, 'Attachments');
attachment := OLE2.INVOKE_OBJ(msg_attch, 'add') ;
OLE2.SET_PROPERTY(attachment, 'name', Attch);
OLE2.SET_PROPERTY(attachment, 'position', 0);
OLE2.SET_PROPERTY(attachment, 'type', 1); /* 1 => MAPI File Data */
OLE2.SET_PROPERTY(attachment, 'source', Attch);
/* Read the attachment from the file */
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, Attch);
OLE2.INVOKE(attachment, 'ReadFromFile', args);
OLE2.DESTROY_ARGLIST(args);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 1); /* 1 => save copy */
OLE2.ADD_ARG(args, 0); /* 0 => no dialog */
/* Send the message without any dialog box, saving a copy in the Outbox */
OLE2.INVOKE(message1, 'Send', args);
OLE2.DESTROY_ARGLIST(args);
MESSAGE('Message successfully sent');
END;
END;
The Mailx package contains three procedures:
1. Procedure Mailx.logon( profile IN VARCHAR2 DEFAULT NULL);
-----------
Use this procedure to logon to the MS Exchange mail
client. The procedure takes a character argument which specifies the
Exchange Profile to use for logon. Passing a NULL argument
to the logon procedure brings up a dialog box that asks you
to choose a profile from a list of valid profiles or create a new one
if it does not exist.
2. Procedure Mailx.send(
----------
Recipient IN VARCHAR2,
Subject IN VARCHAR2 DEFAULT NULL,
Text IN VARCHAR2 DEFAULT NULL,
Attachment IN VARCHAR2 DEFAULT NULL );
This is the procedure that actually sends the message and
attachments, if any, to the recipient. The recipient may be specified directly
as a valid email address or as
an alias defined in the address book. If the message is intended for a fax recipient,
a valid alias must be used
that is defined as a fax address in the address book.
3. Procedure Mailx.logoff;
------------
This procedure closes the Exchange session and deallocates
the resources used by the OLE automation objects.
Sample Application:
-------------------------
1. Create the Mailx Package using the following two Program
Units:
(a) Mailx Package Spec
(b) Mailx Package Body
Mailx Package Spec:
-------------------
PACKAGE Mailx IS session OLE2.OBJ_TYPE; /* OLE object handle */
args OLE2.LIST_TYPE; /* handle to OLE argument list */
PROCEDURE logon( Profile IN VARCHAR2 DEFAULT NULL ); PROCEDURE logoff;
PROCEDURE send( Recp IN VARCHAR2, Subject IN VARCHAR2,
Text IN VARCHAR2,
Attch IN VARCHAR2 );
END;
Mailx Package Body:
------------------
PACKAGE BODY Mailx IS
session_outbox OLE2.OBJ_TYPE;
session_outbox_messages OLE2.OBJ_TYPE;
message1 OLE2.OBJ_TYPE;
msg_recp OLE2.OBJ_TYPE;
recipient OLE2.OBJ_TYPE;
msg_attch OLE2.OBJ_TYPE;
attachment OLE2.OBJ_TYPE;
PROCEDURE logon( Profile IN VARCHAR2 DEFAULT NULL ) IS
BEGIN
session := OLE2.CREATE_OBJ('mapi.session'); /* create the session object */
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, Profile); /* Specify a valid profile name */
OLE2.INVOKE(session, 'Logon', args); /* to avoid the logon dialog box */
OLE2.DESTROY_ARGLIST(args);
END;
PROCEDURE logoff IS
BEGIN
OLE2.INVOKE(session, 'Logoff'); /* Logoff the session and deallocate the */
/* resources for all the OLE objects */
OLE2.RELEASE_OBJ(session);
OLE2.RELEASE_OBJ(session_outbox);
OLE2.RELEASE_OBJ(session_outbox_messages);
OLE2.RELEASE_OBJ(message1);
OLE2.RELEASE_OBJ(msg_recp);
OLE2.RELEASE_OBJ(recipient);
OLE2.RELEASE_OBJ(msg_attch);
OLE2.RELEASE_OBJ(attachment);
END;
PROCEDURE send( Recp IN VARCHAR2,
Subject IN VARCHAR2,
Text IN VARCHAR2,
Attch IN VARCHAR2 ) IS
BEGIN
/* Add a new object message1 to the outbox */
session_outbox := OLE2.GET_OBJ_PROPERTY(session, 'outbox');
session_outbox_messages := OLE2.GET_OBJ_PROPERTY(session_outbox, 'messages');
message1 := OLE2.INVOKE_OBJ(session_outbox_messages, 'Add');
OLE2.SET_PROPERTY(message1, 'subject', Subject);
OLE2.SET_PROPERTY(message1, 'text', Text);
/* Add a recipient object to the message1.Recipients collection */
msg_recp := OLE2.GET_OBJ_PROPERTY(message1, 'Recipients');
recipient := OLE2.INVOKE_OBJ(msg_recp, 'add') ;
OLE2.SET_PROPERTY(recipient, 'name', Recp);
OLE2.SET_PROPERTY(recipient, 'type', 1);
OLE2.INVOKE(recipient, 'resolve');
/* Add an attachment object to the message1.Attachments collection */
msg_attch := OLE2.GET_OBJ_PROPERTY(message1, 'Attachments');
attachment := OLE2.INVOKE_OBJ(msg_attch, 'add') ;
OLE2.SET_PROPERTY(attachment, 'name', Attch);
OLE2.SET_PROPERTY(attachment, 'position', 0);
OLE2.SET_PROPERTY(attachment, 'type', 1); /* 1 => MAPI File Data */
OLE2.SET_PROPERTY(attachment, 'source', Attch);
/* Read the attachment from the file */
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, Attch);
OLE2.INVOKE(attachment, 'ReadFromFile', args);
OLE2.DESTROY_ARGLIST(args);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 1); /* 1 => save copy */
OLE2.ADD_ARG(args, 0); /* 0 => no dialog */
/* Send the message without any dialog box, saving a copy in the Outbox */
OLE2.INVOKE(message1, 'Send', args);
OLE2.DESTROY_ARGLIST(args);
MESSAGE('Message successfully sent');
END;
END;