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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending FAX through reports6i

Status
Not open for further replies.

avinashhegde

Programmer
Sep 12, 2003
2
KW
Can someone tell me the steps to send a FAX through Reports6i. The PC's are in a network. Example will be appreciated.
 
Hi,
Following note might help you.

Programmatically Sending a Fax/Email via Microsoft Exchange

===========================================================

Introduction:
-------------
This explains how to programmatically send a fax/email
message from a Forms/Reports application via Microsoft
Exchange without any kind of user interaction. It shows
the general usage of the 'Mailx' package, as well as a fully coded Forms
sample application.
The concept of OLE (Object Linking and Embedding) automation is used to
control the OLE server application (Microsoft Exchange)
using the client application. The client in this case may be a Developer/2000
Forms or Reports application.
It uses the objects and methods exposed by the OLE Messaging Library which are
much more robust than the
MSMAPI OCX controls and allow access to many more MAPI properties.
Oracle provides support for OLE automation in its applications by means of
the OLE2 built-in package.
This package contains object types and built-ins for creating and manipulating
the OLE objects.
Some of these built-ins (e.g., OLE2.CREATE_OBJ, OLE2.INVOKE,OLE2.SET_PROPERTY)
have been extensively used in the code.
Note for Windows 95 Users:
--------------------------
The example in this code assumes that the OLE Messaging Library is properly
installed on your machine (typically, by installing Exchange in Windows NT).
Since the OLE Messaging Library was released after Windows
95, it is NOT included as a part of the Windows 95 Exchange
client.

General Usage:
--------------
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;

Conclusion:
-----------
This concept/code can be extended to programmatically fax/email an Oracle Report
without any user interaction. To fax a report, first generate the report output
as a PDF file then send this to the fax recipient as an attachment using the
same Mailx Package.

Regards
Himanshu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top