Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: call Outlook or something else to send an email
Nicolas Dezaire wrote:
>
> Thanks,
> it's exactly what i want to do,
> but i'm a beginner in forms and i didn't found how to call
> a windows API function...
> If you know that.
>
> Nico
>
> Christian Kaas a écrit dans le message
> <3888d916.106621763_at_businessnews.de.uu.net>...
> ><ndezaire_at_theleme.com> wrote:
> >
> >>Hi,
> >>I use Forms 4.5 and i'd like to send a mail from my application
> >>by calling outlook or something else.
> >>Does any one knows how to do this ?
> >
> >You can to that with the Windows API Function "ShellExecute" if you
> >supply the command parameter with somehting like "mailto:
> >address_at_provider" then windows will start the registered windows email
> >client for you in dialog mode (pops up the email compose window).
> >With shellexecute you can also open any kind of document or URL.
> >
> >IF you need something different - compose the whole email from within
> >form you probably have to use the ole2 package and drive outlook from
> >there.
> >
> >
This should help:
Bookmark Fixed font Go to End
Doc ID: Note:47498.1
Folder:
Topic:
Subject: Integrating Forms with MAPI on NT 4.0 & Windows 95
Creation date: : 10-OCT-1997
Last Revision Date: 14-MAY-1998
Product: Generic
Document ID: 13000147.6 Title: Programmatically sending a Fax/Email via Microsoft Exchange Author: Varun Puri (vpuri.in) Department: IN: IPEC-ESG Creation Date: 26 May 1997 Last Revision Date: 04 Feb 1998 Expiration Date: 26 May 1998 Revision Number: 3 Distribution Code: External Category: SQL*Forms Product: Developer/2000 Forms Product Version: V45 Platform: Windows 95, WindowsNT 4.0 Information Type: Advisory Impact: Medium Abstract: This bulletin explains how to programmatically send a fax/email from a Forms/Reports application via Microsoft Exchange using OLE2 Keywords:
Programmatically sending a Fax/Email via Microsoft Exchange ===========================================================
INTRODUCTION:
This bulletin 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 for
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 bulletin assumes that the OLE Messaging Library was
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. I have included a simple
script and
the necessary files to install this OLE Messaging component which is
archived in
OLEW95.ZIP file. This can be obtained by accessing the following URL:
ftp://anonymous:userid@www-ess8.oracle.com/desktop/download/olem95.zip
Replace userid by your valid user id on MetaLink.
GENERAL USAGE:
The Mailx package contains three procedures:
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 then 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 FORMS APPLICATION:
(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);
End;
procedure send( Recp IN varchar2, Subject IN varchar2, Text IN varchar2, Attch IN varchar2 )is
/* 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; 2. Create a block called MAPIOLE with the following canvas layout:
|-----------------------------------------------------------------------| | | | Exchange Profile: |====================| | | | | To: |============================| | | | | Subject: |============================| | | | | Message: |============================| | | | | | | | | | | | | | | | | | | | | | | |============================| | | |-----------| | | Attachment: |============================| | SEND | | | |-----------||
|-----------------------------------------------------------------------|
The layout contains 5 text-itmes:
and a 'Send' button with the following WHEN-BUTTON-PRESSED trigger:
Mailx.logon(:profile); Mailx.send(:to,:subject,:message,:attch); Mailx.logoff;
CONCLUSION:
This bulletin explained how to create a sample Forms application which
can send
a fax/email using OLE automation. The same concept/code can be extended
to
programmatically fax/email an Oracle Report without any user
interaction. In
order to fax a report, first generate the report output as a PDF file
and then
send this to the fax recipient as an attachment using the same Mailx
Package.
REFERENCES:
Oracle India Development Center Electronic Services Group
Information from Oracle Corporate Repository.
.
Copyright (c) 1995,1998, Oracle Corporation. All Rights Reserved. Legal Notices and Terms of Use.
--
"Some days you're the pigeon, and some days you're the statue." Received on Thu Jan 13 2000 - 04:41:59 CST
![]() |
![]() |